You can get filename and its path easily by the string operation function included in JavaScript.

var url = "https://google.com/chunkang/kurapa.jpg";
var filename = url.substring(url.lastIndexOf('/')+1); // filename = "kurapa.jpg"
var path = url.replace(filename,""); // path = "https://google.com/chunkang/"