Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if file exists javascript

function executeIfFileExist(src, callback) {
    var xhr = new XMLHttpRequest()
    xhr.onreadystatechange = function() {
        if (this.readyState === this.DONE) {
            callback()
        }
    }
    xhr.open('HEAD', src)
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #file #exists #javascript
ADD COMMENT
Topic
Name
4+9 =