I have to implement file upload feature in my phonegap project. User should be able to upload any type of file from the phone memory or sd card. I tried input type="file", but is not supported in android 4.4. I tried phonegap camera API too, but it is supported only media files. I found cordova file chooser plugin (https://github.com/cdibened/filechooser) would be helpful, but I am unable to make it work. The success callback function is not immediately getting triggered after the file selection. Please find my code below,
<input type="file" id="fileinput" name="fileinput"/>
$("#fileinput").bind('click',function(){
console.log("choose file selected");
filechooser.open( {}, fileChooseSuccess, fileChooseFailed );
});
function fileChooseSuccess(data) {
var filepath = data.filepath;
console.log("file path:"+filepath);
}
function fileChooseFailed(msg) {
console.log(msg);
}
The first success callback function is getting triggered when the user select the second file. Likewise second success callback function is getting triggered when the user select the third file (tested with Android 4.4.2).I am unable to resolve this issue. Is the first argument for “filechooser.open” is mandatory ? What I have to pass for supporting all file types?
In the plugin documentation, its written that “You should change com.ianhanniballake.localstorage.documents in your Manifest, as well as the LocalStorageProvider.AUTHORITY field”. What I have to change?
Any suggestions are greatly appreciated.