file format validation

On October 2, 2009, in Javascript, Linux, Tips, Tricks, by Sandeep Verma

Hits: 89  Below is the code to check file type in javascript.. <script type=”text/javascript” language=”javascript”> function isImage(file) { var image    = /\.(jpg|jpeg|bmp|gif|png|jpe)$/i; if (image.test(file)) return true; else return false; } function isAudio(file) { var audio    = /\.(mp3|wav|mid|midi|mp2|ul|ra|m3u|ram|rm)$/i; if (audio.test(file)) return true; else return false; } function isArchive(file) { var archive    = /\.(zip|rar)$/i; if (archive.test(file)) return true; [...]

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...