How do you get a path from a file object which is returned from an html5 input field?
Basically the phonegap app is setup to go online and download a sound file from a thirdparty website, then browse to the downloaded file and move it to the local directory. (short < 1 sec sound files).
The problem is that file objects attribute .fullPath is undefined. and getFile takes a path input, not an [object File] input.
From the following code:
<input style="opacity:0;" type="file" name="soundInput" id="soundInput"/>
<script type="text/javascript" charset="utf-8">
var soundInput = document.getElementById('soundInput');
soundInput.addEventListener('change', function(){handleFileSelect(type);}, false);
soundInput.click();
function handleFileSelect() {
var file = this.files[0]; // FileList object
var type = isThumpy;
alert("file = " + file.name + "\n full path = " + file.fullPath);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
gotFS(fs,file,type);
}, fail);
}
function fail(error) {
alert("error " + error.code);
}
function gotFS(fileSystem, file, type) {
alert("got filesystem");
var flags = {create: false, exclusive: false};
fileSystem.root.getFile(file, flags, function(fe){
gotFileEntry(type,fe);
},fail);
}
function gotFileEntry(type, fileEntry) {
alert("got fileEntry");
fileEntry.copyTo(path, function(fe){successfulCopy(type, fe);}, fail);
}
function successfulCopy(type, fileEntry) {
alert("copy success");
setSoundByUri(type, fileEntry.name)
}
</script>
It doesn't get past "got filesystem", and it doesn't throw an error ("error " + error.code). Please help.