Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve the C:\fakepath?

People also ask

Why does my file path say Fakepath?

When someone uploads a resume to Crelate, they may notice the 'fakepath' along side the file name. The fakepath note there is the security implementation of your browser. Some browsers have a security feature that prevents JavaScript from knowing your file's local full path.


Some browsers have a security feature that prevents JavaScript from knowing your file's local full path. It makes sense - as a client, you don't want the server to know your local machine's filesystem. It would be nice if all browsers did this.


Use

document.getElementById("file-id").files[0].name; 

instead of

document.getElementById('file-id').value

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

Example:

var input = document.getElementById("inputFile");
var fReader = new FileReader();
fReader.readAsDataURL(input.files[0]);
fReader.onloadend = function(event){
    var img = document.getElementById("yourImgTag");
    img.src = event.target.result;
}

If you go to Internet Explorer, Tools, Internet Option, Security, Custom, find the "Include local directory path When uploading files to a server" (it is quite a ways down) and click on "Enable" . This will work