2

how to get a real path of a file using input type="file" i.e :

HTML Code:

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

when user click on brows button, he will select a file, so i wanted a path from where he selected. Through Jquery (or any possible way ) if i get a value of 'filedata' i.e:

Jquery :

 var filename = $('#fileData').val();

it gives like this C:\fakepath\SO_Status.xlsx

but what i realy wanted is path of a file and not data inside a file / no need to upload a file C:\filesFolder\SO_Status.xlsx (assuming 'SO_Status.xlsx' file present in fakepath)

putvande
  • 15,068
  • 3
  • 34
  • 50
Rajesh Hatwar
  • 1,843
  • 6
  • 39
  • 58

1 Answers1

2

What are you trying to do is not possible due to security reasons.

Also, check this answer: https://stackoverflow.com/a/15201258/706273

Joe DF
  • 5,438
  • 6
  • 41
  • 63
Alex B.
  • 647
  • 7
  • 21
  • i gone through it, but it is not what i relay wanted – Rajesh Hatwar Jun 06 '14 at 10:06
  • @RajeshHatwar That's what I'm saying - due to security reasons it is not possible to do it. – Alex B. Jun 06 '14 at 10:08
  • Also, why would you like to know the full path? There might be a workaround for your particular needs. – Alex B. Jun 06 '14 at 10:15
  • yes i have, I am working on a Library Software. some times users will keep E-books on some location and while entering a Non-Book details they save soft copy path of it – Rajesh Hatwar Jun 06 '14 at 10:33
  • In this case the `` element will not be sufficient. You will have to write your own local-filepath selector using the underlaying technology (PHP, or any other). Check this question: http://bit.ly/1pdMzZn – Alex B. Jun 06 '14 at 10:55
  • @RajeshHatwar Use $('#fileData')[0].files[0].path – Zik Apr 19 '17 at 11:56