This is post about how to get the filetype from file name. nothing special just using split() and pop() function
<script>
filename = 'test.php';
alert(filename.split(.).pop());
</script>
alert will return php, because the split function split the filename and return a array as [0]=>'test', [1]=>php.
pop() will pop the last value from array.
<script>
filename = 'test.php';
alert(filename.split(.).pop());
</script>
alert will return php, because the split function split the filename and return a array as [0]=>'test', [1]=>php.
pop() will pop the last value from array.
No comments:
Post a Comment