本文介绍了< input type ='file'>为IE提供完整路径,只需要文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当从IE浏览器执行上传时,我的后端(org.apache.commons.fileupload)获取完整的文件路径。



对于其他非IE浏览器文件名,它的安全性是OK的。



如何从IE的输入中获取 >

是否可以在UI上执行,因为我认为编辑apache lib并不是很优雅。



也许,一些参数存在于输入字段?



我可以在服务器上执行,但对UI方法感兴趣。

解决方案

文件输入的要点是提供一个文件。随附的名称是无论浏览器供应商如何使用,它们不能保证与文件系统上的文件名有任何关系。



您无法更改浏览器发送的内容。



如果您要使用浏览器发送的名称,那么您需要确保它对您的任何内容都有效要做到这一点(例如确保它只包含文件系统中文件名中允许的字符)。这使得它必须在服务器上处理(就像任何其他客户端提供的数据一样)。


When perform uploading from IE browser, that my backend(org.apache.commons.fileupload) gets full file path.

For other non-IE browsers it gets filename and it's OK because of security.

How to get filename only from input for IE?

Is it possible to do on UI, because I think it's not very graceful to edit apache lib.

Maybe , some parameter exists for input field?

I can do it on server, but interested in UI approach.

解决方案

The point of the file input is to provide a file. Names that come with it are "whatever the browser vendor feels like using", they aren't guaranteed to have anything to do with the file name on the file system at all.

You can't change what the browser sends.

If you are going to make use of the name sent by the browser, then you need to make sure it is valid for whatever you are going to do with it (e.g. make sure it only includes characters that are allowed in filenames on your filesystem). This makes it something that must be handled on the server (just like any other client supplied data).

这篇关于< input type ='file'>为IE提供完整路径,只需要文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 07:47