Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to this answer: <a href="https://stackoverflow.com/questions/11754299/phonegap-android-unable-to-upload-image-using-filetransfer">Phonegap android unable to upload image using fileTransfer</a> You cannot use the URI directly....</p> <p>But, it seems the uri can be used directly... (see my code below)</p> <p><strong>Edit 25-7-2013</strong> I got this working with: call like this:</p> <pre><code>navigator.camera.getPicture(onPhotoUriSuccess, onFailCamera, { quality: 50, destinationType: pictDestinationType.FILE_URI }); </code></pre> <p>and on succes:</p> <pre><code>function onPhotoUriSuccess(imageUriToUpload){ var url=encodeURI("http://your_url_for_the_post/"); var username='your_user'; var password='your_pwd'; var params = new Object(); params.your_param_name = "something"; //you can send additional info with the file var options = new FileUploadOptions(); options.fileKey = "the_name_of_the_image_field"; //depends on the api options.fileName = imageUriToUpload.substr(imageUriToUpload.lastIndexOf('/')+1); options.mimeType = "image/jpeg"; options.params = params; options.chunkedMode = true; //this is important to send both data and files var headers={'Authorization':"Basic " + Base64.encode(username + ":" + password)}; options.headers = headers; var ft = new FileTransfer(); ft.upload(imageUriToUpload, url, succesFileTransfer, errorFileTransfer, options); } </code></pre> <p>By the way, I use an apache webserver on the api site, I saw here, nginx could have a problem with the chunked mode: <a href="https://stackoverflow.com/questions/9736588/phonegap-chunckedmode-true-upload-error">PhoneGap chunckedMode true upload error</a></p>
 

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