0

我正在使用 phonegap 的文件传输 api 将 000000001.db 文件上传到服务器,但它给了我错误文件未找到错误代码 = 1 谁能帮我解决这个问题。

function uploadFile() {
    alert('uploading file');
    // Get URI of picture to upload
    var img = document.getElementById('camera_image');
   // var imageURI = img.src;

   //"/data/data/com.suave.nexttrainer/app_database/file_0/0000000001.db";
    //i am giving physical address of database of simulator here 
    var imageURI = "/data/data/com.suave.nexttrainer/app_database/file_0/0000000001.db";
 // Verify server has been entered
    server = document.getElementById('serverUrl').value;
    alert('server');
    if (server) {

        // Specify transfer options
        var options = new FileUploadOptions();
        options.fileKey="file";
        options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
        options.mimeType="image/jpeg";
        options.chunkedMode = false;

        // Transfer picture/file to server
        var ft = new FileTransfer();
        alert('ft');
        ft.upload(imageURI, server, function(r) {
            document.getElementById('camera_status').innerHTML = "Upload successful: "+r.bytesSent+" bytes uploaded.";              
        }, function(error) {
            document.getElementById('camera_status').innerHTML = "Upload failed: Code = "+error.code;               
        }, options);
    }
4

1 回答 1

0

两件事情:

1)尝试使用

"var imageURI = "file:///data/data/com.suave.nexttrainer/app_database/file_0/0000000001.db";

2) com.suave.netxtrainer 是您的应用程序包吗?因为只有该应用程序可以从该目录中读取。

于 2013-02-19T16:42:40.007 回答