Why do browsers present selected files as coming from C:\fakepath\ instead of their true local path?

dom, file-upload, html, javascript

Solution

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.

Problem

``` <input type="file" onchange="this.nextElementSibling.textContent = this.value;"> <p> ``` When I pick a file from the input above, I get a path like this: C:\fakepath\test.csv or this (Mozilla): test.csv I want the fully qualified local file path. How to resolve this issue? If this is due to browser security issue then what should be the alternate way to do this?

Original source

Related problems