Initial conditions:
var fullPath = 'folder1/folder2/folder3/filename.jpg';
What need get:
filename.jpg
Code example:
var fileName = '';
if (fullPath) {
var startIndex = (fullPath.indexOf('\\') >= 0
? fullPath.lastIndexOf('\\')
: fullPath.lastIndexOf('/'))
;
var fileName = fullPath.substring(startIndex);
if (fileName.indexOf('\\') === 0 || fileName.indexOf('/') === 0) {
fileName = fileName.substring(1);
}
}
This is the place for you to tell a litle bit about your self. Just write your name, age, hobbies or anything else.
Sorry, no comments yet.