简体   繁体   English

需要从客户端计算机获取上传文件的完整路径

[英]Needed to take the full path of the uploaded file from client Machine

I just needed to take the full path of the uploaded file from client Machine. 我只需要从客户端计算机获取上载文件的完整路径。

I tried 我试过了

strDir = Upload1.PostedFile.FileName

strDir = System.IO.Path.GetFullPath(Upload1.PostedFile.FileName)

with upload control, but it doesn't work that kind. 带有上传控件,但这种方法不起作用。

I too know that security concerns will not allow the server to be aware of the file path, but are there any other alternate options to retrieve the file path. 我也很清楚,出于安全考虑,服务器无法知道文件路径,但是还有其他替代方法可以检索文件路径。 If yes please reply to the post.... 如果是,请回复该帖子。

You cannot, unless you create/register a protocol handler that can communicate with the OS, or perhaps create an ActiveX control (works only with IE) or a Java applet. 除非您创建/注册了可以与操作系统进行通信的协议处理程序,否则您将无法创建,或者创建ActiveX控件(仅适用于IE)或Java小程序。 Browsers don't natively communicate with the computer. 浏览器不会与计算机进行本地通信。

Don't waste your time. 不要浪费你的时间。

For security reasons browsers do no allow get client path, ie JavaScript in browser has no access to the File System, however using HTML5 File API, only Firefox provides a mozFullPath property, but fortunately if you try to get the value it returns an empty string: 出于安全原因,浏览器不允许获取客户端路径,即浏览器中的JavaScript无法访问文件系统,但是使用HTML5 File API,只有Firefox提供了mozFullPath属性,但是幸运的是,如果您尝试获取该值,它将返回一个空字符串:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM