user1107939
user1107939

Reputation: 51

HTML file select and JavaScript

I need to fetch complete the path from file select element of HTML using JavaScript. I have returned a JavaScript function, but it fetches only file name not the complete path.

How can I get the complete file path?

Upvotes: 0

Views: 550

Answers (1)

Alex Wayne
Alex Wayne

Reputation: 187004

You can't. It's due to security. The browser only provides the content and the filename.

Providing the path could allow an attacker to learn things about the files on your hard drive that they want kept private. Do you really want to let the web server know that the kitty.png you are uploading for your avatar was actually in c:/pr0n/?

No, I didn't think so.

Upvotes: 2

Related Questions