如何使用 Jquery 获取文件的真实路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24079117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 02:27:03  来源:igfitidea点击:

How To Get Real Path Of A File Using Jquery

jqueryfile-upload

提问by Rajesh Hatwar

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

如何使用 input type="file" 获取文件的真实路径,即:

HTML Code:

HTML代码:

<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(或任何可能的方式),即:

Jquery :

查询:

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

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

它给出这样的 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)

但我真正想要的是文件路径而不是文件中的数据/不需要上传文件C:\filesFolder\SO_Status.xlsx(假设“SO_Status.xlsx”文件存在于fakepath中)

采纳答案by Alex B.

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

由于安全原因,您尝试执行的操作是不可能的。

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

另外,检查这个答案:https: //stackoverflow.com/a/15201258/706273