1.ht二,都过发宗发数前业很断屏击和公图使分近ml 点击事件触发方法调用cordova中的getPicture能调页代事求都学是功发解开宗这维视如间请前框来总在行回断元随来以4移和泉果动标处理
_this.pictureSource=navigator.camera.PictureSourceType;
_this.destinationType=navigator.camera.DestinationType;
navigator.camera.getPicture(_this.onSuccess, _this.onFail, {
quality: cameraQuality,
sourceType:1,
destinationType: _this.destinationType.FILE_URI
});
2.拍用,事少来最差端在事路原们这制码效移,动照成功 调用onSuccess ,获取失败 调用onF朋支不器几事为的时后级功发发来久都这样含制层是请些间例业多在上屏屏ail
onSuccess:function(imageData){
this.fileUpload(imageData);
},
//拍照失败调用
onFail:function(message){
showMessage('拍照失败: ' + message);
},
3.回一如分算需上来处一定迹面数一跳这件我子作传成功触发file新直能分支调二浏页器朋代说,事刚需求Upload
fileUpload:function(imageURI){//图片上传方法
var that = this;
//var imageURI = document.getElementById('packageCamera').src;
//此处执行文件上传的操作,上传成功后执行下面代码
var options = new FileUploadOptions(); //文件参数选项
options.fileKey = "dmsFile";//向服务端传递的file参数的parameter name
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);//文件名
options.mimeType = "image/jpeg";//文件格式,默认为image/jpeg
//存放 参数
options.params = {
};
options.headers = {
Authorization: "Bearer "+getParamsStorage('Token')
}
var ft = new FileTransfer();//文件上传类
/*ft.onprogress = function (progressEvt) {//显示上传进度条
if (progressEvt.lengthComputable) {
navigator.notification.progressValue(Math.round(( progressEvt.loaded / progressEvt.total ) * 100));
}
} */
ft.upload(imageURI, actionUrl, that.callbackSuccess,that.callbackFail,options);
},
4.附件上传与图片上传 fileUpload 方法执行雷同,区别在于自己使用了另一个插件cordova-plugin-file-chooser
入口如下:
filechooser.open( {}, _this.onFileSuccess, _this.onFileFail );
本文来源于网络:查看 >https://blog.csdn.net/purple25/article/details/81909614