filereader check file type
var fileTypes = ['jpg', 'jpeg', 'png', 'what', 'ever', 'you', 'want']; //acceptable file types
function readURL(input) {
if (input.files && input.files[0]) {
var extension = input.files[0].name.split('.').pop().toLowerCase(), //file extension from input file
isSuccess = fileTypes.indexOf(extension) > -1; //is extension in acceptable types
if (isSuccess) { //yes
var reader = new FileReader();
reader.onload = function (e) {
alert('image has read completely!');
}
reader.readAsDataURL(input.files[0]);
}
else { //no
//warning
}
}
}
Also in JavaScript:
- not getting webhook post request json data in my laravel controller
- js add click listener
- javascript time execution
- javascript object keys foreach
- architecture creation for a react webpack app
- Remove Duplicate objects from JSON
- js math random
- image popup js close button
- javascript continue
- is nodejs code visible client side
- for Loop continue
- alertify js vue
- javascript get element width and height
- object to array javascript
- js clone element
- push a new route only triggers URL change but not location change
- select onchange jquery get the selected option data attribute
- javascript number format
- sass node sass loder
- json objects
- how to convert string to int a array in javascript
- jquery click hold down
- javascript how to sort variables by user input
- javascript remove duplicates from array