I have a full path to an image, which I am using jQuery to read like this:
$('img.my_image').attr('src');
However I just want the filename portion (i.e. without full path).
Are there any built-in functions to do this, or would a regex be the only option?
Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).
GetFileName(String) Returns the file name and extension of the specified path string.
The filename is the last part of the URL from the last trailing slash. For example, if the URL is http://www.example.com/dir/file.html then file. html is the file name.
var Filename= path.split('/').pop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With