我想使用PhoneGap将文件发送到服务器。下面是我要发送的以下函数参数文件的代码。问题是,如果我插入一个假的url作为本地主机服务器,它显示我的服务器错误代码= 2,如果我插入一个真正的url显示我的文件未找到代码=1
function gotFile(file)
{
navigator.notification.alert(file.fullPath);
var options = new FileUploadOptions();
options.mimeType="image/jpg";
options.fileKey="file";
var params = {};
params.IdPrestation = "3d660013-3028-46c3-adfa-d7141a712ed7";
params.IdPhoto = "3a660013-3028-46c3-adfa-d7141a712ed7";
options.params = params;
options.chunkedMode = true ;
var ft = new FileTransfer();
ft.upload(file.fullPath,encodeURI('http://Myserver.fr/Phototheque.asmx/SavePhoto'),function(r)
{
//navigator.notification.alert(r.response,function(){});
alert(r.response,function(){});
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
},
function(e)
{
//navigator.notification.alert('Serveur Erreur:' + e.code,function(){});
cause_erreur(e.code);
/*
alert('Serveur Erreur:' + e.code,function(){});
alert("upload error source " + e.source);
alert("upload error target " + e.target)
*/
},
options
);//ft.upload
}
发布于 2013-02-22 00:11:23
我不太了解你的bug。但是,您的上传代码似乎是正常的,可能会因为文件大小或网络state.The而出现错误。同时,您可以在服务器中查看请求和响应是否正常。
https://stackoverflow.com/questions/15005886
复制相似问题