Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check upload img extension jquery

<input type="file" id="image" accept="image/*" onChange="validate(this.value)"/>

function validate(file) {
    var ext = file.split(".");
    ext = ext[ext.length-1].toLowerCase();      
    var arrayExtensions = ["jpg" , "jpeg", "png", "bmp", "gif"];

    if (arrayExtensions.lastIndexOf(ext) == -1) {
        alert("Wrong extension type.");
        $("#image").val("");
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: laravel http send data json raw 
Javascript :: node js server 
Javascript :: stop a site from reloading javascript 
Javascript :: how to remove duplicate object in array javascript 
Javascript :: js toggle 
Javascript :: javascript change color every second 
Javascript :: axios fetch 
Javascript :: how to serve html node server 
Javascript :: CastError: Cast to ObjectId failed for value "undefined" at path "_id" for model 
Javascript :: preloader js code 
Javascript :: how to go to another page onclick in react 
Javascript :: jquery equivalent of document.getelementbyid 
Javascript :: selector id jquery but is variable 
Javascript :: double click in js 
Javascript :: js know size of screen displayed 
Javascript :: confirm before close modal 
Javascript :: starting express server 
Javascript :: discord token 
Javascript :: javascript ready state 
Javascript :: oneerror javascript image 
Javascript :: remove json javascript 
Javascript :: routes in node js 
Javascript :: promise.race 
Javascript :: useeffect dependency error 
Javascript :: node.js ping 
Javascript :: js array from 
Javascript :: node js response header 
Javascript :: generate numbers from 1 to 100 to array 
Javascript :: import library react js 
Javascript :: regex must match exactly 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =