PhoneGap中文网

 找回密码
 立即注册
查看: 15245|回复: 0
打印 上一主题 下一主题

上传图片问题

[复制链接]

8

主题

14

帖子

146

积分

注册会员

Rank: 2

积分
146
跳转到指定楼层
楼主
发表于 2017-3-16 17:08:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
有一个需求 拍摄照片后直接上传 这是我的代码
  var options = {
    //这些参数可能要配合着使用,比如选择了sourcetype是0,destinationtype要相应的设置
    quality: 75,                                            //相片质量0-100
    destinationType: 2,        //返回类型:DATA_URL= 0,返回作为 base64 編碼字串。 FILE_URI=1,返回影像档的 URI。NATIVE_URI=2,返回图像本机URI (例如,資產庫)
    sourceType: Camera.PictureSourceType.CAMERA,             //从哪里选择图片:PHOTOLIBRARY=0,相机拍照=1,SAVEDPHOTOALBUM=2。0和1其实都是本地图库
    allowEdit: true,                                        //在选择之前允许修改截图
    encodingType: Camera.EncodingType.JPEG,                   //保存的图片格式: JPEG = 0, PNG = 1
    targetWidth: 200,                                        //照片宽度
    targetHeight: 200,                                       //照片高度
    mediaType: 0,                                             //可选媒体类型:圖片=0,只允许选择图片將返回指定DestinationType的参数。 視頻格式=1,允许选择视频,最终返回 FILE_URI。ALLMEDIA= 2,允许所有媒体类型的选择。
    cameraDirection: 0,                                       //枪后摄像头类型:Back= 0,Front-facing = 1
    popoverOptions: CameraPopoverOptions,
    saveToPhotoAlbum: true                                   //保存进手机相册
  };
    $cordovaCamera.getPicture(options).then(function(imageData) {
      uploadFactory.upload(imageData,"myinfoedit")
    }, function(err) {
      // error
    });
}//service中----------------------------------------------------------------upload:function (fileurl,type) {
  function win(r) {
    alert("Code = " + r.responseCode);
    alert("Response = " + r.response);
    alert("Sent = " + r.bytesSent);
  }
  function fail(error) {
    alert("An error has occurred: Code = " + error.code);
    alert("upload error source " + error.source);
    alert("upload error target " + error.target);
  }
  var uri = encodeURI("http://img.udiao.com/act/test.php");
  var options = new FileUploadOptions();
  options.fileKey = "_FILES";
  options.fileName = fileurl.substr(fileurl.lastIndexOf('/') + 1);
  options.mimeType = "image/jpeg";
  var ft = new FileTransfer();//"/storage/emulated/0/DCIM/Camera/1489633260122.jpg"
  ft.upload(fileurl, uri, win, fail, options);
}后台用PHP的 可是一直 报错 错误code=1FILE_NOT_FOUND在网页上测试都没问题 ,请问这是什么原因啊?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

ionic4视频教程

Archiver|手机版|小黑屋| PhoneGap中文网 ( 京ICP备13027796号-1 )  

GMT+8, 2024-4-19 20:40 , Processed in 0.043930 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表