Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript file exists check

// checking existence of file synchronously
function doesFileExist(urlToFile) {
    var xhr = new XMLHttpRequest();
    xhr.open('HEAD', urlToFile, false);
    xhr.send();
     
    return xhr.status !== 404;
}
 
PREVIOUS NEXT
Tagged: #javascript #file #exists #check
ADD COMMENT
Topic
Name
7+1 =