Ron Baas
asked on
javascript delete path
Using JavaScript, how can I get the name of a file without its path or extension?
This:
C:\fakepath\test305.pdf
Should return this:
test305
This:
C:\fakepath\test305.pdf
Should return this:
test305
.... and here is how to get the filename WITHOUT the extension
<script>
var path = 'C:\\fakepath\\test305.pdf';
var parts = path.split('\\');
var filename = parts[parts.length - 1].split('.');
alert(filename[0]);
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
@Ron Baas,
Please advise what was wrong with the first two comments - both of which answer the question.
Please advise what was wrong with the first two comments - both of which answer the question.
Yeah, Julian could also get some points as I suggested in my post :)
Open in new window