Skip to content
Advertisement

Save the name of an image from a url

I need to find a way to get the image name of any given image from a url. For example, in “…/images/foo.png”, the image name is “foo.png”. Is there a way to read this url and save just the name of the image up until the “/”? Thanks!

Advertisement

Answer

You can just use split:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement