[英]Form isnt submitting an input type:file like it should
I was checking with the page it was posting to: hello.aspx, and there were not files inside the Request object. 我正在检查它发布到的页面:hello.aspx,并且Request对象中没有文件。
I used jQuery to move move this input INTO the form after it is assigned a file, so the first thing i dd was to double check to make sure the object was placed correctly with the correct contents. 我使用jQuery移动此输入INTO表单后,它被分配一个文件,所以我要做的第一件事是仔细检查,以确保对象正确放置正确的内容。 (seemingly, yes).
(貌似,是的)。
The form markup ends up looking exactly as follows: 表单标记最终看起来完全如下:
<form enctype="multipart/form-data" method="POST" target="myFrame" action="hello.aspx" id="IE9Images">
<input type="file" class="new_file" />
</form>
Now at first, i was thinking the input would need a name attribute: So i added one: 现在起初,我认为输入需要一个名称属性:所以我添加了一个:
name="myFile"
still nothing in the server request. 服务器请求中仍然没有任何内容 I changed method, thinking it was case sensitive:
我改变了方法,认为它区分大小写:
method="post"
and still nothing. 但仍然没有。
I looked at the attributes of the input, and YES, there is actually a file associated with it: kev.png . 我查看了输入的属性,YES,实际上有一个与之关联的文件: kev.png 。
Is there something obvious i am missing when it comes to forms? 在形式方面,有什么东西显而易见吗? It does actually submit everything correctly, but it doesnt recognize the input.
它实际上确实提交了所有内容,但它不识别输入。
edit: Make sure all inputs in a form have a name so that way it is referenced on the server. 编辑:确保表单中的所有输入都有一个名称,以便在服务器上引用它。
You're missing enctype="multipart/form-data"
. 你缺少
enctype="multipart/form-data"
。
This is required for forms with file-inputs. 对于具有文件输入的表单,这是必需的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.