set to file by url in javascript code example

Example 1: get filename from url js

var filename = location.pathname.substr(location.pathname.lastIndexOf("/")+1);

Example 2: upload file from url javascript

<input type="hidden" name="image-url" value="http://books.google.com/books/content?id=L2byvgEACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api">

<img src="http://books.google.com/books/content?id=L2byvgEACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api"/>