我正在使用phonegap 3.3,当我尝试通过文件传输插件将图片上传到服务器时,我在ios 7上收到错误3和http-status 500,在android上它完美无缺。
我的客户代码:
function onSuccess(imageURI) {
$.mobile.loading('show');
try{
var options = new FileUploadOptions();
options.fileKey='file';
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType='image/jpeg';
var ft = new FileTransfer();
ft.upload(imageURI, path + "/Home/postPicture", win, fail, options);
} catch(err){
$.mobile.loading('hide');
alert(err);
}
}
function win(data) {
var obj = $.parseJSON(data.response);
$("#PictureSource").val(obj.PictureSource);
$.mobile.loading('hide');
}
function fail(error) {
$.mobile.loading('hide');
alert("error " + error.code);
}
function onFail() {
navigator.notification.alert(
'שגיאה לא ידועה...נסה שנית!', // message
alertDismissed, // callback
'שגיאה', // title
'אישור' // buttonName
);
}
function selectInput() {
navigator.notification.confirm(
'בחר את מקור התמונה', // message
onSelect, // callback to invoke
'בחירת מקור', // title
'מצלמה,גלריה, ביטול' // buttonLabels
);
}
function onSelect(input) {
switch(input)
{
case 1:
{
var destinationType = navigator.camera.DestinationType;
var sourceType = navigator.camera.PictureSourceType;
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: destinationType.FILE_URI,
//correctOrientation: true,
sourceType: sourceType.CAMERA
});
}
break;
case 2:
{
var destinationType = navigator.camera.DestinationType;
var sourceType = navigator.camera.PictureSourceType;
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: sourceType.PHOTOLIBRARY
});
}
break;
case 3:
alertDismissed();
break;
default:
alertDismissed();
}
}
function alertDismissed() {
// do nothing
}
和我在ASP.net MVC 4中的服务器端与here几乎相同(我已经嘲笑它,它在android上没有问题)。
请帮忙,
更新:
当我尝试从图库上传图像时,它确实适用于ios,但拍照并上传它不起作用,你是不是一个phonegap / cordova错误?或者它是别的什么?