javascript - Get extension from a file url -


i using file(input) select file. want retrieve file extension(.jpeg) url c:\users\rajat\pictures\pic1.jpeg. after want put url text box according format i.e audio, video , image.

in case better go mimetype instead of extensions.

var fileinput = document.getelementbyid('your-file-input-id'); var filetype = fileinput.files[0].type; console.log(filetype);//gives image/jpeg or audio/mp3 var parts = filetype.split('/'); parts[0];//image parts[1];//jpeg 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -