Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: extract all link with javascript 
Javascript :: loop through array javascript 
Javascript :: npm react pagination 
Javascript :: how to read breakline in html 
Javascript :: jquery when iframe is loaded 
Javascript :: math ceil 
Javascript :: how to target child element of an event object in JS 
Javascript :: check if item not in array node js 
Javascript :: get an array with unique values 
Javascript :: jquery hover and hover out 
Javascript :: http to https redirect express js 
Javascript :: handlerbar console log 
Javascript :: Remove Duplicates array values in javascript 
Javascript :: js float to percentage 
Javascript :: Uncaught TypeError: Object prototype may only be an Object or null: undefined 
Javascript :: javascript in keyword 
Javascript :: get width of div jquery 
Javascript :: import svg react 
Javascript :: json limit 
Javascript :: prisma seed 
Javascript :: javascript declare a variable 
Javascript :: react native apk bundle 
Javascript :: javascript for each loop 
Javascript :: difference between var and let 
Javascript :: Navigator.pushReplacementNamed parameters 
Javascript :: tolocaledatestring format dd-mm-yyyy 
Javascript :: how to change root variable css 
Javascript :: hwo to make ana array of prime numbers in javascript 
Javascript :: js remove html element 
Javascript :: how to move div using jquery 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =