I am currently using the following approach, in which it provides the details of a file, but not the actual object, which seems to us one of those that we get from javascript / jQuery. Does anyone know how to get a file object from a file URI / native URI from the iOS / android mobile file system using cordova and javascript?
Below is the snippet I'm currently using.
window.resolveLocalFileSystemURL( filepath, function(fileEntry) { fileEntry.file( function(file) { var reader = new FileReader(); reader.onloadend = function() { var imgBlob = new Blob([this.result], {type: "image/jpeg"}); var uploadedFile = imgBlob; uploadedFile.name = file.name; alert("Importing Asset from Camera.. " + uploadedFile.name); alert(uploadedFile.type); alert(uploadedFile.size); importAsset(uploadedFile); }; reader.readAsArrayBuffer(file); }, function(error) { alert("Error in fileEntry.file():" + error) }) }, function(error) { alert("Error in window.resolveLocalFileSystemURL():" + error) } );
Note: FileTransfer.upload() will not work in my case.
Above the fragment that I use after you take from the Add image file to form data - Cordova / Angular after passing through the existing Q & A from #SO
javascript android ios cordova phonegap
Sagar pudi
source share