处理 plus.io.resolveLocalFileSystemURL IOS上传图片兼容问题
处理 plus.io.resolveLocalFileSystemURL IOS上传图片兼容问题
问题:plus.io.resolveLocalFileSystemURL ios 报错 不允许读
处理方式:指定下视频保存的路径
{ filename: "_doc/camera/", filter: "image", system: false }
代码例子:
相册选择:
plus.gallery.pick( function(filePath) { alert(filePath); plus.io.resolveLocalFileSystemURL( filePath, function(entry) { entry.file(function(file) { let reader = null; reader = new plus.io.FileReader(); reader.onload = function(e) {}; reader.readAsDataURL(file); reader.onloadend = function(e) { let dataBase = e.target.result; uploadImgBase64({ file: dataBase }) .then(res => { if (res.data.code === 200) { _this.alertVal = "图片上传成功"; _this.showPluginAuto(); } else { _this.alertVal = res.data.msg; _this.showPluginAuto(); } }) .catch(() => { _this.alertVal = "图片上传失败!"; _this.showPluginAuto(); }); }; }); }, function(e) {} ); }, function(e) {}, { filename: "_doc/camera/", filter: "image", system: false } );
拍照上传:
let camera = plus.camera.getCamera(); camera.captureImage( function(filePath) { alert(filePath); plus.io.resolveLocalFileSystemURL( filePath, function(entry) { entry.file(function(file) { let reader = null; reader = new plus.io.FileReader(); reader.onload = function(e) {}; reader.readAsDataURL(file); reader.onloadend = function(e) { let dataBase = e.target.result; uploadImgBase64({ file: dataBase }) .then(res => { if (res.data.code === 200) { _this.alertVal = "图片上传成功"; _this.showPluginAuto(); } else { _this.alertVal = res.data.msg; _this.showPluginAuto(); } }) .catch(() => { _this.alertVal = "图片上传失败!"; _this.showPluginAuto(); }); }; }); }, function(e) {} ); }, function(e) {}, { filename: "_doc/camera/", index: 1 } );