Try this, var pictureName = PicName1.substring(PicName1.lastIndexOf('/') + 1); In your case it will return "PhotoName1.jpg" [Look this thread](http://stackoverflow.com/questions/1302306/how-to-pull-the-file-name-from-a-url-using-javascript-jquery)