Created
July 31, 2015 13:27
-
-
Save cdmz/1741bf9c81285e3f3260 to your computer and use it in GitHub Desktop.
Get extension file by path javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = "http://localhost/project/temp/folder/file.mp4"; | |
var array = path.split('/'); // split / | |
var ultimo = array.pop(); // get last index | |
var basename = ultimo.split('.'); // splt . | |
var extension = basename.pop(); // get last index | |
alert(extension); | |
// OR | |
var path ="http://localhost/project/temp/folder/file.mp4"; | |
var array = path.split('.'); // splt . | |
extension = array[array.length -1 ]; // get last index | |
alert(extension); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment