<输入类型=‘文件’>对于 IE 给出完整路径,只需要文件名 [英] <input type=‘file’> for IE gives full path, need file name only

查看:27
本文介绍了<输入类型=‘文件’>对于 IE 给出完整路径,只需要文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

对于其他非 IE 浏览器,它获取文件名,出于安全考虑,这没问题.

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

如何仅从 IE 的输入中获取文件名?

How to get filename only from input for IE?

是否可以在UI上做,因为我觉得编辑apache lib不是很优雅.

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?

我可以在服务器上完成,但对 UI 方法感兴趣.

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).

这篇关于<输入类型=‘文件’>对于 IE 给出完整路径,只需要文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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