How To Get Real Path Of A File Using Jquery [dupli

2019-07-17 16:18发布

问题:

This question already has an answer here:

  • How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax? 10 answers
  • How to resolve the C:\fakepath? 11 answers

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)

回答1:

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

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