Phonegap android unable to upload image using fileTransfer

前端 未结 2 1332
长情又很酷
长情又很酷 2020-12-07 04:21

I\'m trying to capture an image using the camera and upload it to my AJAX endpoint. I\'ve confirmed that this endpoint can accept the file (I created a test HTML file on my

相关标签:
2条回答
  • 2020-12-07 05:09

    After puzzling a bit, it seems to me you can use the image uri directly....

    see my answer here: (this works for me on android):

    android phonegap camera and image uploading

    0 讨论(0)
  • 2020-12-07 05:18

    You can not use imageUri that you get from camera success callback in FileTransfer upload method, you have to first resolve uri as a filename like this:

    navigator.camera.getPicture(function(imageURI){
    
          window.resolveLocalFileSystemURI(imageUri, function(fileEntry) {
                fileEntry.file(function(fileObj) {
    
                    var fileName = fileObj.fullPath;
    
                    //now use the fileName in your method
                    //ft.upload(fileName ,serverURL + '/ajax.php?fname=appuploadspotimage'...);
    
                });
            });
    });
    
    0 讨论(0)
提交回复
热议问题