如何使用jQuery获取文件的真实路径 [英] How To Get Real Path Of A File Using Jquery

查看:629
本文介绍了如何使用jQuery获取文件的真实路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

HTML代码:

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

当用户单击浏览"按钮时,他将选择一个文件,所以我想要一个他选择的路径.通过jQuery(或任何可能的方式),如果我得到'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();

它给出了这样的C:\fakepath\SO_Status.xlsx

但是我真正想要的是文件的路径,而不是文件中的数据/无需上传文件C:\filesFolder\SO_Status.xlsx(假设falsepath中存在'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)

推荐答案

由于安全原因,您试图做什么是不可能的.

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

也请检查以下答案: https://stackoverflow.com/a/15201258/706273

这篇关于如何使用jQuery获取文件的真实路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆