1
我正面臨上傳文件在ios phonegap大的問題,但同樣是工作的android.When我上傳文件從iphone,它給了我200即成功和發送的字節。但服務器響應是目標缺失,這意味着該文件沒有在服務器上接收,請儘可能提供給我任何解決方案。因爲無法實現項目的死線。 Thanks.I'm將在這裏分享我的代碼。上傳文件不在iphone iphone phonegap但在Android中工作正常
function upload_demo() {
// Retrieve image file location from specified source
navigator.camera.getPicture(
uploadPhoto1,
function(message) { alert('get picture failed'); },
{
quality : 50,
destinationType : navigator.camera.DestinationType.FILE_URI,
sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY
}
);
}
function uploadPhoto1(imageURI) {
alert(imageURI);
alert(activefolder);
var url="https://server.com/****";
alert(url);
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var headers = {
"Authorization" : auth
};
options.headers = headers;
var params = {};
params.target = activefolder;
options.params = params;
options.httpMethod="POST";
alert(JSON.stringify(options));
var ft = new FileTransfer();
ft.upload(imageURI, encodeURI(url), win1, fail1, options,true);
}
function win1(r) {
alert("Code = " + r.responseCode);
alert("Response = " + r.response);
alert("Sent = " + r.bytesSent);
}
function fail1(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
任何一個有關於這個問題的任何想法你的plist ??? #phonegap #cordova –