-2

I have trying get full path of uploading file, but i can't take that. My code is here

HTML

<input type="file" id="file">

Javascript code

 console.log(document.getElementById("file").value);

output

C:\fakepath\image.jpg

I want to know full path of the file.

Gowrishankar RJ
  • 171
  • 2
  • 2
  • 11
  • 1
    Why do you want the local file system path? – Bharat Jain Apr 09 '16 at 05:58
  • _“I want to know full path of the file”_ – well, you can’t. It’s a security/privacy issue; just because I upload a file to your server, doesn’t make my local file system structure/folder names any of your business. – CBroe Apr 09 '16 at 06:05
  • Ask Users to use IE6 – YOU Apr 09 '16 at 09:45

2 Answers2

2

There is no way to get full path of uploading file. Browsers have a security feature that prevents JavaScript from knowing your file's local full path. It is good that as a client, you don't want the server to know your local machine's filesystem. It is good if all browsers does this from the security point of view.

Bharat Jain
  • 500
  • 3
  • 15
0

Javascript has no powers to access the file system from the client end (Browser). Its all about security reasons.

But using HTML5 File API, only Firefox has a mozFullPath property, Even it will return null if you try to get the value of the file path. So i can say that you cant get the file path.

Please refer the following link also.

Link_1

Community
  • 1
  • 1
Ramkee
  • 900
  • 1
  • 10
  • 27