Phonegap android unable to upload image using fileTransfer

前端 未结 2 1336
长情又很酷
长情又很酷 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: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'...);
    
                });
            });
    });
    

提交回复
热议问题