2013-02-19 70 views
0

我上传000000001.db文件到服务器通过使用文件传输API的phonegap,但它给了我错误 文件未找到错误代码= 1 任何人都可以帮助我如何摆脱这件事。如何使用phonegap的文件传输API将000000001.db文件上传到服务器?

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); 
    } 
+0

你解决这个问题 – Aravin 2014-12-09 12:56:52

回答

0

两件事情:

1)尝试使用

“VAR imageURI = “文件:///data/data/com.suave.nexttrainer/app_database/file_0/0000000001.db” ;

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

+0

我喜欢这一点,但在我的日志猫就说明这一点?。 02-20 01:50:51.194 E/FileTransfer(1624):{“target”:“http:\/\/nextrainer.com \/nexdbbackup \ /upload.php”,“source”:“文件:\/\/\/data \/data \ /com.suave.nexttrainer \/app_database \/file_0 \ /0000000001.db“,”code“:1} 02-20 01:50:51.194: FileTransfer(1624):java.io.FileNotFoundException:/data/data/com.suave.nexttrainer/app_database/file_0/0000000001.db:打开失败:ENOENT(无此文件或目录) 其上的服务器的路径我必须上传数据库文件“http://nextrainer.com/nexdbbackup/upload.php” – 2013-02-20 10:54:02

+0

西蒙你有任何想法上传0000000001.db即数据库文件到一些服务器 – 2013-02-20 11:32:57

+0

西蒙你有任何想法上传00000000001.db即数据库文件到某个服务器实际上我想要采取类似数据库的备份如果设备在这种情况下被盗或破坏,我们应该备份我们的数据库..你对此有何评论? – 2013-02-20 11:33:47

相关问题