javascript - How to resolve the C:fakepath

javascript – How to resolve the C:fakepath?

javascript – How to resolve the C:fakepath?

Some browsers have a security feature that prevents JavaScript from knowing your files local full path. It makes sense – as a client, you dont want the server to know your local machines filesystem. It would be nice if all browsers did this.



instead of


javascript – How to resolve the C:fakepath?

I use the object FileReader on the input onchange event for your input file type! This example uses the readAsDataURL function and for that reason you should have an tag. The FileReader object also has readAsBinaryString to get the binary data, which can later be used to create the same file on your server


var input = document.getElementById(inputFile);
var fReader = new FileReader();
fReader.onloadend = function(event){
    var img = document.getElementById(yourImgTag);
    img.src =;

Related posts on java script  :

Leave a Reply

Your email address will not be published.