Note that there are some explanatory texts on larger screens.

plurals
  1. POPhoneGap Ajax Upload File
    primarykey
    data
    text
    <p>I am trying to run <a href="http://docs.phonegap.com/en/1.5.0/phonegap_file_file.md.html#FileTransfer" rel="nofollow">this</a> PhoneGap example for uploading images from the device to the server.</p> <pre><code> // Wait for PhoneGap to load // document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap is ready // function onDeviceReady() { // Retrieve image file location from specified source navigator.camera.getPicture(uploadPhoto, function(message) { alert('get picture failed'); }, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY } ); } function uploadPhoto(imageURI) { var options = new FileUploadOptions(); options.fileKey="file"; options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); options.mimeType="image/jpeg"; var params = new Object(); params.value1 = "test"; params.value2 = "param"; options.params = params; var ft = new FileTransfer(); ft.upload(imageURI, "http://some.server.com/upload.php", win, fail, options); } function win(r) { alert("Code = " + r.responseCode); alert("Response = " + r.response); console.log("Sent = " + r.bytesSent); } function fail(error) { alert("An error has occurred: Code = " + error.code); alert("upload error source " + error.source); alert("upload error target " + error.target); } </code></pre> <p>In my case, unlike the example mentioned above, I am not using a php file which posting data into the database, but using a secure url to post it directly via HTML. Something which will look on a desktop version like that:</p> <pre><code>&lt;form action="https://mySecureUrl.com/?filename=myImage" method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="myfile"&gt;&lt;br&gt; &lt;input type="submit" value="Upload File to Server"&gt; &lt;/form&gt; </code></pre> <p>Now I am trying to apply the same method using PhoneGap FileTransfer() and I get error code 3.</p> <pre><code>var ft = new FileTransfer(); ft.upload(imageURI, encodeURI("https://mySecureUrl.com/?filename=myImage.jpg"), win, fail, options); </code></pre> <ul> <li>Is it possible to post file like in this method on PhoneGap? How?</li> <li>If not, what is the php solution for that?</li> </ul>
    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.
    1. This table or related slice is empty.
    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