check if file exists javascript
JavaScript
<!DOCTYPE HTML>
<html>
<head>
<title>
How to check if file exist or
not on HTTP status is 200
</title>
<style>
body {
text-align: center;
}
h1 {
color: green;
}
#output {
color: green;
font-size: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<h1>
GeeksforGeeks
</h1>
<label id="File_Path">
<b>Enter File Path: </b>
</label>
<input type="text" id="File_URL">
<button id="Check_File" onclick="checkFileExist()">
click here
</button>
<p id="output"></p>
<script>
var url = document.getElementById("File_URL");
var output = document.getElementById("output");
var http = new XMLHttpRequest();
function checkFileExist() {
if (url.length === 0) {
output.innerHTML = "Please enter File URL";
} else {
http.open('HEAD', url, false);
http.send();
if (http.status === 200) {
output.innerHTML = "File exists";
} else {
output.innerHTML = "File doesn't exists";
}
}
}
</script>
</body>
</html>
function executeIfFileExist(src, callback) {
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function() {
if (this.readyState === this.DONE) {
callback()
}
}
xhr.open('HEAD', src)
}
Also in JavaScript:
- Title
- add elements to an array with splice
- Category
- JavaScript
- Title
- fromjson method convert integer to double
- Category
- JavaScript
- Title
- firefox extension make ajax request
- Category
- JavaScript
- Title
- how to make a property important in javascript
- Category
- JavaScript
- Title
- angular 8 to 9
- Category
- JavaScript
- Title
- devexpress dxdatagrid custom text field
- Category
- JavaScript
- Title
- download image in nodejs
- Category
- JavaScript
- Title
- filter out arrays js
- Category
- JavaScript
- Title
- how to get the height of window in javascript
- Category
- JavaScript
- Title
- javascript Check if an element is a descendant of another
- Category
- JavaScript
- Title
- Elements in iteration expect to have 'v-bind:key' directives
- Category
- JavaScript
- Title
- how to make ajax request javascript
- Category
- JavaScript
- Title
- detect browser javascript
- Category
- JavaScript
- Title
- crypto.com api
- Category
- JavaScript
- Title
- how to pass a variable to jspf
- Category
- JavaScript
- Title
- flutter cache json
- Category
- JavaScript
- Title
- get x, y of element js
- Category
- JavaScript
- Title
- Find the stray number
- Category
- JavaScript
- Title
- dom is loaded
- Category
- JavaScript
- Title
- comment obtenir l'élément parent javascript
- Category
- JavaScript
- Title
- get width of a dom element js
- Category
- JavaScript
- Title
- how to show hide div in html javascript
- Category
- JavaScript
- Title
- how to limit input type max length
- Category
- JavaScript
- Title
- javascript add to a dictionary
- Category
- JavaScript
- Title
- How to check whether a string contains a substring in JavaScript?
- Category
- JavaScript
- Title
- how to add headers to the server response node js
- Category
- JavaScript
- Title
- how to get today date in javascript
- Category
- JavaScript
- Title
- get page resolution jquery
- Category
- JavaScript
- Title
- how to make a text editor in html
- Category
- JavaScript
- Title
- delete with unlinksync node
- Category
- JavaScript
- Title
- how to instialise var in js
- Category
- JavaScript
- Title
- express fingerprint
- Category
- JavaScript
- Title
- How to append to a file in Node?
- Category
- JavaScript
- Title
- How to create a nested schema in apollo graphql server
- Category
- JavaScript
- Title
- how to auto refresh page in javascript
- Category
- JavaScript
- Title
- git remote url change
- Category
- JavaScript
- Title
- how to get the end of an array javascript
- Category
- JavaScript
- Title
- javascript base64 encode
- Category
- JavaScript
- Title
- Javascript get random item from array
- Category
- JavaScript
- Title
- how to add script before </body> in magento 2
- Category
- JavaScript
- Title
- can we import jquery library from developer tools
- Category
- JavaScript
- Title
- how to use custom stylesheets express node
- Category
- JavaScript
- Title
- button style not working react native
- Category
- JavaScript
- Title
- chrome extension dynamically add javascript
- Category
- JavaScript
- Title
- global site tag (gtag.js) - google analytics gatsby
- Category
- JavaScript
- Title
- he href attribute is required for an anchor to be keyboard accessible
- Category
- JavaScript
- Title
- get current time epoch javascript
- Category
- JavaScript
- Title
- how to loop over dom objects javascript
- Category
- JavaScript
- Title
- extend react.component
- Category
- JavaScript
- Title
- auto refresh page javascript
- Category
- JavaScript
- Title
- drupal 8 check if current page is node
- Category
- JavaScript
- Title
- ajax open a request
- Category
- JavaScript
- Title
- how to make a circle in js
- Category
- JavaScript
- Title
- express route parameters
- Category
- JavaScript
- Title
- ion-fab-button ionic angular
- Category
- JavaScript
- Title
- javascript and
- Category
- JavaScript
- Title
- get browser timezone javascript
- Category
- JavaScript
- Title
- express get query params from url
- Category
- JavaScript
- Title
- javascript array pop
- Category
- JavaScript
- Title
- defining props in react
- Category
- JavaScript
- Title
- axios post with header
- Category
- JavaScript
- Title
- javascript change image src
- Category
- JavaScript
- Title
- convert object to json javascript
- Category
- JavaScript
- Title
- how to run function after animation complete jquery
- Category
- JavaScript
- Title
- create react native app npx
- Category
- JavaScript
- Title
- generate thumbnail of pdf using pf js
- Category
- JavaScript
- Title
- append new element for each value in array d3.js
- Category
- JavaScript
- Title
- integers to space separated string in javascript
- Category
- JavaScript
- Title
- go to anchor jquery
- Category
- JavaScript
- Title
- javascript change web page title
- Category
- JavaScript
- Title
- clone a JavaScript object
- Category
- JavaScript
- Title
- iterate over object javascript
- Category
- JavaScript
- Title
- change width in js
- Category
- JavaScript
- Title
- how to update kali linux on virtualbox
- Category
- JavaScript
- Title
- how to write in js
- Category
- JavaScript
- Title
- format date javascript
- Category
- JavaScript
- Title
- how to make a textarea unwritable in react native
- Category
- JavaScript
- Title
- default props react
- Category
- JavaScript
- Title
- how to remove a property from an object in javascript
- Category
- JavaScript
- Title
- display none in jquery
- Category
- JavaScript
- Title
- add to json object javascript
- Category
- JavaScript
- Title
- how to deep copy object in javascript
- Category
- JavaScript
- Title
- get all a tags javascript
- Category
- JavaScript
- Title
- how to change list item text color in react
- Category
- JavaScript
- Title
- how to make text come up with javascript
- Category
- JavaScript
- Title
- get current url js
- Category
- JavaScript
- Title
- ellipsis javascript
- Category
- JavaScript
- Title
- events js 292 throw er Unhandled 'error' event ^ Error getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0 at GetAddrInfoReqWrap.onlookup [as oncomplete]
- Category
- JavaScript
- Title
- access angular app outside localhost
- Category
- JavaScript
- Title
- bubble sort javascript
- Category
- JavaScript
- Title
- for(let [key,val] in obj){ messageBody = messageBody.replace("{"+ key + "}",val) }
- Category
- JavaScript
- Title
- javascript bind event to created element
- Category
- JavaScript
- Title
- window location in react
- Category
- JavaScript
- Title
- javascript array column
- Category
- JavaScript
- Title
- How to abreviate digits in js
- Category
- JavaScript
- Title
- dynsmic calss in react add
- Category
- JavaScript
- Title
- angular reactive forms
- Category
- JavaScript
- Title
- array reverse algorithm in js
- Category
- JavaScript
- Title
- credit card mask js
- Category
- JavaScript
- Title
- html how to type a long string in many lines
- Category
- JavaScript