Is it possible to have two “<input type=file>” within a single form?

两盒软妹~` 提交于 2019-12-12 12:15:55

问题


Is it possible to have something like the following

<form id="uploadForm" action="upload.ashx" method="post" enctype="multipart/form-data">
<p>Upload File 1</p>
<input type="file" name="file1"/>
<p>Upload File 2</p>
<input type="file" name="file2"/>
<input type="submit" value="Submit" />
</form>

I know I can use the Jquery Multi-File-Upload plugin to upload multiple files from a single input element. The situation is that the end user will be uploading multiple images of a product and I would like to be able to prompt them for sep. image for example one could be a front view and the second could be a back view. When I try the above HTML however I only see the first file being posted in Firebug.

Update:

Looks like this may be something with Firebug as when I modify the dest .ashx page to just spit back the filenames that it received from the post request I get both Files. Also in the Firebug console I see this message buried amongst the posted data ... Firebug request size limit has been reached by Firebug. ...


回答1:


That works fine for me. The files are being uploaded to my server just fine.




回答2:


The inputs have the same name. Change the names or in PHP for example you can use the shortcut name=file[] and have an array



来源:https://stackoverflow.com/questions/4107276/is-it-possible-to-have-two-input-type-file-within-a-single-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!