我正在开发一个使用phonegap的Android应用程序,其中我使用cordova 3.5.1.jar,从2.9.0 cordova升级后需要插件和cordova 3.5.1js文件。上传我在下面使用的相机图像和视频function.here我无法将图像上传到服务器。当我调试它时,我发现window.resolveLocalFileSystemURI()函数没有执行,而在filetransfer插件中它执行errorcallback函数失败。请在代码中出现错误指导我解决这个问题。
插件中的filetransfer.js
var self = this;
var win = function(result) {
if (typeof result.lengthComputable != "undefined") {
if (self.onprogress) {
self.onprogress(newProgressEvent(result));
}
} else {
successCallback && successCallback(result);
}
};
exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
};
var fail = errorCallback && function(e) {
var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
//alert("error");
errorCallback(error);
};
的index.html
function uploadimage(resid) {
var fileName;
for(var i=0;i<Locphotos.length;i++)
{
if (!Locphotos[i]) {
return;
}
fileName= Locphotos[i];
/* window.resolveLocalFileSystemURI(Locphotos[i], function (fileEntry) {
fileEntry.file(function (fileObj) {
fileName = fileObj.fullPath;});
}); */
server = "http://mangitna/service.asmx?op=UploadFile";
if (server) {
// Specify transfer options
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = resid+"-A-" + fileName.substr(fileName.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
options.headers = {
Connection: "close"
};
var ftLocphotos = new FileTransfer();
ftLocphotos.upload(fileName, server, function (r) {
}, function (error) {
}, options);
}
}
}
更新:
注释resolveLocalFileSystemURL函数后。