在文件上传中获取真实路径而不是"fakepath" [英] Get real path instead of 'fakepath' in file upload
问题描述
我遇到以下问题:
当用户使用HTML文件输入上传文件时,我想接收文件路径本身.例如,我只得到 C:/fakepath/filename.txt
.
When a user uploads a file with the HTML file input and I then want to receive the file path itself. I only get C:/fakepath/filename.txt
for example.
我了解这是浏览器知道文件确切路径的安全原因.因此,我想知道是否有可能通过某种方式,.net中的某种方式或其他jquery/js插件来获取文件的完整路径.
I understand that it is a security reason for browsers to know the exact path of the file. So i was wondering if it is even possible with some hack, some way in .net or with additional jquery/js plugin to get the full path of the file.
为什么?
我们不想将文件本身上传到我们的服务器文件系统,也不想上传到数据库.我们只想将本地路径存储在数据库中,以便当同一用户打开站点时,他可以单击该路径,然后打开其本地文件系统.
We dont want to upload the file itself to our server filesystem, neither to the database. We just want to store the local path in the database so when the same user opens the site, he can click on that path and his local file system opens.
对此方法有何建议或建议?
Any suggestions or recommendations for this approach?
如果真的不可能这样
我想我们需要提出一个不同的想法.但是,由于某些答案确实很老,我想也许现在已经有解决方案了.谢谢大家
we would need to come up with a diffrent idea I guess. But since some of the answers are really old, I thought maybe there is a solution to it by now. Thx everyone
推荐答案
由于浏览器的设计不允许这样做,因此您需要在浏览器框外运行自己的代码.
You'll need your own code running outside browser-box to do this, since browsers are designed NOT to allow this.
我的意思是像ActiveX,Flash,COM对象,自定义浏览器扩展或其他奇特的安全漏洞一样丑陋的东西可以打开它自己的OpenFileDialog并将该值插入您的输入字段中.
I mean something ugly like ActiveX, flash, COM object, custom browser extenstion or other fancy security breach that can open it's own OpenFileDialog and insert that value in your input field.
这篇关于在文件上传中获取真实路径而不是"fakepath"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!