android - How to upload any type of file in phonegap and jquery mobile ? -


i creating app in phonegap android in want upload file server. want when user click on upload button option dialog open user select file uploaded , when user click on save button file uploaded. dialog normal window same see when click on attach button in mail in desktop. can tell me how in android mobile? appreciated.

thanks in advance.

use phonegap file transfer method filetransfer object allows upload or download files , server.

properties

  1. onprogress: called progressevent whenever new chunk of data transferred. (function)

methods

  • upload: sends file server.

  • download: downloads file server.

  • abort: aborts in-progress transfer.

sample // !! assumes variable fileuri contains valid uri text file on device

var win = function (r) {     console.log("code = " + r.responsecode);     console.log("response = " + r.response);     console.log("sent = " + r.bytessent); }  var fail = function (error) {     alert("an error has occurred: code = " + error.code);     console.log("upload error source " + error.source);     console.log("upload error target " + error.target); }  var options = new fileuploadoptions(); options.filekey = "file"; options.filename = fileuri.substr(fileuri.lastindexof('/') + 1); options.mimetype = "text/plain";  var params = {}; params.value1 = "test"; params.value2 = "param";  options.params = params;  var ft = new filetransfer(); ft.upload(fileuri, encodeuri("http://some.server.com/upload.php"), win, fail, options); 

you can browse , select file using

var source =  navigator.camera.picturesourcetype.photolibrary; navigator.camera.getpicture(successfn, errorfn, { quality: 50,         destinationtype: this.photodestinationtype.file_uri,         sourcetype: source,         mediatype: navigator.camera.mediatype.allmedia  }); 

more information check link


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -