jQuery find file extension (from string)

Posted by SoulieBaby on Stack Overflow See other posts from Stack Overflow or by SoulieBaby
Published on 2010-06-15T03:17:48Z Indexed on 2010/06/15 3:22 UTC
Read the original article Hit count: 532

Filed under:
|
|

Hi all, I was wondering if it was possible for jQuery to find a file extension based on a returned string?

A filename (string) will be passed to a function (openFile) and I wanted that function to do different things based on what file has been passed through, it could be image files or pdf files.

function openFile(file) { 

  //if .jpg/.gif/.png do something

  //if .zip/.rar do something else

  //if .pdf do something else

};

I've been looking for something that will find the file's extension but I can't seem to find anything.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about file