Cordova check if file in url exists
Try code from this link: https://cordovablogsblogs.wordpress.com/2015/06/10/how-to-check-a-files-existence-in-phone-directory-with-phonegap/. Code:
function checkIfFileExists(path){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
fileSystem.root.getFile(path, { create: false }, fileExists, fileDoesNotExist);
}, getFSFail); //of requestFileSystem
}
function fileExists(fileEntry){
alert("File " + fileEntry.fullPath + " exists!");
}
function fileDoesNotExist(){
alert("file does not exist");
}
function getFSFail(evt) {
console.log(evt.target.error.code);
}
Update: Works on iOS too.
Try:
function checkIfFileExists(path){
// path is the full absolute path to the file.
window.resolveLocalFileSystemURL(path, fileExists, fileDoesNotExist);
}
function fileExists(fileEntry){
alert("File " + fileEntry.fullPath + " exists!");
}
function fileDoesNotExist(){
alert("file does not exist");
}
Found the solution here.
Works on Android. Will test on iOS and update this answer.