Cordova/Phonegap FileTransfer.upload()错误代码= 1(FILE_NOT_FOUND_ERR)

ror*_*ory 6 javascript phonegap-plugins cordova phonegap-build cordova-plugins

真正令人困惑的是,当我使用手机摄像头拍摄图像时,我使用FileTransfer.moveTo它并根据需要将图像发送到SD卡上的指定文件夹.我还保留了一个图像对象列表localStorage,看起来像这样:

[
Object
ean: "42208556"
image: "file:///storage/sdcard0/PhotoscanPhotos/d51b5b77-aab1-9947-096d-b0a92dfb87eafoto.jpg"
timestamp: 1396441761000
__proto__: Object
etc etc
Run Code Online (Sandbox Code Playgroud)

作为我的应用程序的一部分,我使用相同的图像[i] .image作为src属性动态添加图像到列表,它工作正常.但是,使用相同的参数FileTransfer.upload会给出上述错误.

我的函数几乎是API文档的复制品(Cordova 3.1).代码如下:

function uploadImagesAsJpegs(imageObject) {
    var options = new FileUploadOptions();
    options.fileKey = "file";
    options.fileName=imageObject.image.substr(imageObject.image.lastIndexOf('/')+1);
    //alert(options.fileName);//debugging ............we're happy with this
    options.mimeType="image/jpeg";
    options.chunkedMode = true;

    var serverUrl = http://172.17.7.112/mylocalserver;


    var params = {};
    params.value1 = ean;
    params.value2 = imageObject.timestamp;

    options.params = params;

    var fileTransfer = new FileTransfer();

    //alert(encodeURI(serverURL));//debugging  ............we're happy with this
    //alert("image to upload is: " + imageObject.image);//debugging............we're happy with this
    fileTransfer.upload(imageObject.image, encodeURI(serverURL), onUploadSuccess, onUploadFail, options);
}
Run Code Online (Sandbox Code Playgroud)

Anh*_*dir 7

我相信设置options.chunkedMode = false;是在文件上传期间解决大多数问题,也许试一试.


ror*_*ory 1

服务器端脚本是错误的......鉴于明显的错误消息,我自然应该弄清楚这一点FileTransferError.FILE_NOT_FOUND_ERR。对于浪费大家的时间表示歉意,并感谢您所做的努力。