我正在尝试使用 phonegap 发送图像文件filetransfer.upload
,但是返回的文件已损坏,并且查看 logcat 发送的文件似乎太短了 200 个字节。
这是我发送文件的代码
sendImageFile = function (imageURI, imageName) {
writelog("Sending image file", 1);
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "image name";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
writelog("image uri length " + imageURI.length, 1);
writelog("Image options set up successfully", 1);
var ft = new FileTransfer();
ft.upload(imageURI, uploadurl, win, transFail, options);
}
这里有一些来自 logcat 的相关行
01-07 12:27:30.743: D/FileTransfer(20066): Uploaded 114688 of 145432 bytes
01-07 12:27:31.571: D/FileTransfer(20066): got response from server
01-07 12:27:31.696: D/CordovaLog(20066): Code = 200
01-07 12:27:31.696: D/CordovaLog(20066): Response = 12099
01-07 12:27:31.696: D/CordovaLog(20066): Sent = 145236
任何帮助将不胜感激。
谢谢
马特