In Coldfusion, I tried to find the function to find the index value of last occurrence of /
in file path so that file name after /
is picked up. can any body suggest me the solution. I want to retrieve file name from a file path.
Use GetFileFromPath(filepath)
. It returns the file name from a given path.
<cfset fileName = GetFileFromPath(filepath)>
You could either use listLast()
to get the fragment of the string you want directly:
filePart = listLast(fullPath, "/\");
Or you could simply use java.lang.String's lastIndexOf()
method to approach it exactly the way you describe.
However I'd just use listLast()
.
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