|
How can i get file extensions with javascript?
i have a file titled \'file.png\' i want js function to return me \'png\'
2 Answers
Keep it simple :)
function getFileExtension(filename) {
return filename.split('.').pop();
}
Posted: misterx704 1 of 1 people found this answer helpful. Did you? Yes No
Should do it.
function getFileExtension(filename) {
return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined;
}
Posted: xtremex 1 of 1 people found this answer helpful. Did you? Yes No |
© Advanced Web Core. All rights reserved

