简体   繁体   English

如何从适用于 IE 和 FireFox 的 asp.net 文件上传控件获取文件名?

[英]How do i get the file name from an asp.net fileupload control that works in IE and FireFox?

In firefox i do get the file name (not the full path from where the file is uploaded) using fileuploadID.postedfile.filename .在 firefox 中,我确实使用fileuploadID.postedfile.filename获取文件名(不是上传文件的完整路径)。 But the same thing retrieves full path (from where the file is uploaded) in IE.但同样的事情在 IE 中检索完整路径(从文件上传的位置)。

Any one please tell me how to get the filename browser compatibly.任何人请告诉我如何兼容地获取文件名浏览器。

Firefox by default sends only the filename. Firefox 默认只发送文件名。 But that should be enough to get the name.但这应该足以获得名称。 Once you get the name, it is enough for you, because it is already uploaded to the temp folder (location is unimportant).获得名称后,对您来说就足够了,因为它已经上传到临时文件夹(位置不重要)。 Once you have the filename handle, you can copy it wherever.一旦你有了文件名句柄,你就可以把它复制到任何地方。 Alternatively, you can use Path.GetFileName(filename) that should get you the same results in both the browsers....或者,您可以使用Path.GetFileName(filename)应该在两个浏览器中获得相同的结果....

http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspxhttp://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx

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

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