|
拍照后无法上传,返回的json数据为:{code:null, source:null, target:null, http_status:null, body:null, exception:null}
Model.prototype.btnUploadImageClick = function(event){
//var deferred = when.defer();
var imageURI = './img/banner1.jpg'; //localStorage.getItem("attendPhotoFile");
var options = new FileUploadOptions();
options.fileKey = "attendphotox5file";// 用于设置参数
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
// 如果是图片格式,就用image/jpeg,其他文件格式上官网查API
options.mimeType = "image/jpeg";
// 这里的uri根据自己的需求设定,是一个接收上传图片的地址
var uri = encodeURIComponent(webapi.BASE_URL.replace('api/', '') + "SetImageUpload.ashx?userid=" + localStorage.getItem('HongHuaMobileLoginUserID') + '&jsoncallback=?');
options.chunkedMode = false;
var params = new Object();
params.id = "1";
params.name = "test";
options.params = params;
var ft = new FileTransfer();
function success(result) {
//deferred.resolve(imageURI);//改变执行状态
//navigator.notification.progressStop();
alert("成功" + JSON.stringify(result));
}
function fail(message) {
alert("失败:" + JSON.stringify(message));
}
// 上传回调
//ft.onprogress = showUploadingProgress;
//navigator.notification.progressStart("", "当前上传进度");
ft.upload(imageURI, uri, success, fail, options);
};
|
|