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
Post a Comment