Base64 image javascript

From there the image has to be saved locally on my system. The code I am using: var imagepath = $("#imageid").val();// from this getting the path of the selected image that var st = imagepath.replace(data:image/png or jpg; base64"/""); Convert image to Base64 online and use the result string as data URI, img src, CSS background-url, and others. ................
................