我有一个带有以下上传 javascript 的应用程序:
function take_image() {
navigator.camera.getPicture(uploadPhoto, function(message) {alert('get picture failed');}, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
}
);
}
function uploadPhoto(localURI) {
window.resolveLocalFileSystemURI(localURI, function(fileEntry) {
myURI=fileEntry.fullPath;
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=myURI.substr(myURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = true;
var ft = new FileTransfer();
ft.upload(myURI, "http://www.mydomain.co.uk/uploadimage.php", win, fail, options);
alert(myURI + " uploading");
}, resolveFail);
}
这会在那里停留大约 5 分钟,并在 ft.upload 调用中出现错误代码 1(未找到文件)。
我已经使用 resolveLocalFileSystemURI 来绕过有时从 navigator.camera.getPicture 获得的奇怪路径,我最初认为这就是问题所在。上传的文件路径看起来不错,但经过深思熟虑后却找不到文件。
用这个尝试了一切,演示代码根本不起作用。会不会是权限问题?