检索使用Firefox上传文件的完整路径(服务器端)? [英] Retrieving the full path (server-side) of a file uploaded using Firefox?

查看:140
本文介绍了检索使用Firefox上传文件的完整路径(服务器端)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用一个包含< input id =myFiletype =filerunat =server/> 的表单来上传文件时,服务器端代码在使用Firefox时只能看到没有完整路径的文件名,而在IE中可以正常工作。

是否可以检索完整的文件路径server-在这种情况下呢?

解决方案

你不行。实际上,大多数情况下只有IE提供的这个信息对于服务器来说并不重要。至少,FF和Opera都不提供这些信息。

[更新]也尝试过使用Safari,仍然没有路径...有人报告说,Chrome可能会提供信息,虽然是一个测试版,可能会改变...



也许你可能需要他们在一些内联网的情况下。在这种情况下,您可能会要求用户将路径粘贴到辅助输入字段中。不太友好,但至少他们会知道他们提供了信息。



其实,我知道有些人因为某些原因需要这些信息,所以他们使用JavaScript从文件输入字段中选取路径并将其放在隐藏字段中。 FF开发人员发现它是不安全的(你可以从一个简单的路径学习很多...就像用户的登录名!),所以禁止在FF3这样的用法,使一些人生气对这个版本...



参考文献: Firefox 3的文件上传框文件输入框禁用导致很大的可用性问题,其他很多。


When I am using a form containing <input id="myFile" type="file" runat="server" /> to upload a file, my server-side code only sees the filename without the full path when using Firefox, while it works just fine in IE.

Is it possible to retrieve the full file path server-side in this case?

解决方案

You cannot. Actually, only IE gives this information which isn't important for the server in most cases. Neither FF nor Opera, at least, provide this info.
[UPDATE] Also tried with Safari, still no path... Somebody reported that Chrome might provide the info, although being a beta, that might change...

Perhaps you might need them in some intranet cases. In such case, you might ask the user to paste the path in a secondary input field... Not very friendly, but at least they will know they provide the info.

Actually, I know some people needed this info for some reasons, so they used JavaScript to pick up the path from the file input field and put it in an hidden field. FF developers found it was insecure (you can learn a lot from a simple path... like the login name of the user!) so prohibited such usage in FF3, making some people angry against this release...

References: Firefox 3's file upload box mentioned in Firefox 3 annoyance: Keying-in disabled in file upload control ...; also File input box disabled leads to great usability problem, among many other ones.

这篇关于检索使用Firefox上传文件的完整路径(服务器端)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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