Monday, 13 June 2016

cordova - FileUploader plugin (PhoneGap) for iPhone



I am trying to use the PhoneGap FileUploader plugin to upload an image from iPhone to my server




How do I use the uploadByUri function exactly? I don't understand all the parameters...



FileUploader.prototype.uploadByUri("http://www.mysite.com/images/", imageURI,
params, fileKey, "myimage", "image/jpg", uploadSuccess, uploadFail, uploadProgress)


What do I use for for "params" and "filekey"? The read-me file says:






  • fileKey Parameter name of the file

  • params Object with key: value params to send to the server




Right now I am putting null and get no errors, but there is no image in my destination folder.



Also, do you know if I can upload directly an image in base64-encoded string from the camera rather than an image from the album?



Thank you for your help.




Roberto


Answer



The fileKey is the name of the file field that the server is expecting. So if you were uploading a file via a web app you would have an and the server would be looking for the "fileKey" to get the file data.



Params is unused I believe.



Uploading a base64 encoded image would be just like uploading a text file I assume. On the server you would need to convert it to an image file.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...