Note that there are some explanatory texts on larger screens.

plurals
  1. POPhonegap android unable to upload image using fileTransfer
    primarykey
    data
    text
    <p>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 desktop that sends a form with an image in it). I'm using Cordova (phonegap) 1.7.0, and am trying to get the fileTransfer() to work. Here is the link for the documentation that I followed:</p> <p><a href="http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer" rel="nofollow">http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer</a></p> <p>The success callback triggers, but no $_FILES data is to be found on the endpoint. </p> <p>I then found this article:</p> <p><a href="http://zacvineyard.com/blog/2011/03/25/upload-a-file-to-a-remote-server-with-phonegap/" rel="nofollow">http://zacvineyard.com/blog/2011/03/25/upload-a-file-to-a-remote-server-with-phonegap/</a></p> <p>Which suggested using <code>options.chunkedMode = false</code>. Now the upload takes an age and a half, before eventually failing with an error code of 3, which I believe is <code>FileError.ABORT_ERR</code>. </p> <p>Am I missing something?</p> <p>My code from the app below:</p> <pre><code> navigator.camera.getPicture(function(imageURI){ console.log('take success! uploading...'); console.log(imageURI); var options = new FileUploadOptions(); options.fileKey = 'file'; options.fileName = 'spot_image.jpeg'; options.mimeType = 'image/jpeg'; var params = new Object(); params.spot_id = 1788; params.param2 = 'something else'; options.params = params; options.chunkedMode = false; var ft = new FileTransfer(); ft.upload(imageURI,serverURL + '/ajax.php?fname=appuploadspotimage',function(r){ console.log('upload success!'); console.log(r.responseCode); console.log(r.response); console.log(r.bytesSent); },function(error){ console.log('upload error') console.log(error.code); },options,true); console.log('after upload'); },function(message){ console.log('fail!'); console.log(message); },{ quality: 50, destinationType: navigator.camera.DestinationType.DATA_URL, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY }); </code></pre> <p><code>serverURL</code> is defined as the domain for my AJAX endpoint, which has been whitelisted in cordova.xml.</p> <p>I've seen a number of questions here in SO regarding this, which varying opinions as to whether chunkedMode should be used. Anyone having this issue as well?</p> <p>Am trying this on a Samsung Galaxy S, running ICS. </p> <p>May the person who helps me solve this issue mysteriously inherit a beer factory. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload