尝试上载Internet Explorer中不存在的文件,未提交表单 [英] Trying to upload a non-existent file in Internet Explorer, form is not submitted
问题描述
我有一个带有input type=file
的表格. Internet Explorer允许用户在该输入中键入所需的任何内容(而Firefox会显示一个文件选择器).如果用户输入了明显无效的名称,例如:
I have a form with an input type=file
. Internet Explorer lets the user type anything they want into that input (whereas Firefox brings up a file chooser). If the user enters a blatantly invalid name, for example:
a
并尝试提交表单,Internet Explorer甚至不尝试提交表单.
and tries to submit the form, Internet Explorer does not even try to submit the form.
有什么办法让我知道这已经发生了吗,并让用户知道这是正在发生警报吗?
Is there any way for me to know that this has happened and let user know this is happening with an alert?
推荐答案
我找到了一种更好的方法: http://www.priddypictures.co.uk/reference/fileInputProblem.htm
I found a better way to do this: http://www.priddypictures.co.uk/reference/fileInputProblem.htm
因此,如果那些家伙/女孩是正确的,并且如果输入不具有name属性,则Form会很好地提交,则:
So, if those guys/gals are right, and form submits fine if the input does not have a name attribute then:
- 编写一个jQuery插件(如果使用Internet Explorer,则从所有文件输入中删除name属性)
- 将另一个具有正确名称的隐藏输入插入表单
- 将值从文件输入复制到隐藏输入
我可能会在某个时候编写此插件.
I might write this plug-in at some point.
这篇关于尝试上载Internet Explorer中不存在的文件,未提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!