Reputation: 7
I am developing an Android application using phonegap and I need to know how upload a file (images and videos) through JavaScript.
Can anybody help me with this?, give me any idea or something..
The application consume WCF Rest web services.
Thanks!
Upvotes: 0
Views: 297
Reputation: 4972
Use the filetransfer API - http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer should do the trick :)
Edit - To use the filetransfer you would do something like this..
var options = new FileUploadOptions();
options.fileKey="photo";
options.fileName=fileURI.substr(fileURI.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(fileURI, "http://some.server.com/upload.php", win, fail, options);
Make sure you're defining the fileURI. On your server you would be looking for a post with a name of "photo" or what ever you call the fileKey.
Upvotes: 3