问题描述
在一个HTML页面上,我希望允许一个用户选择多个文件并将其上传到我的服务器。具体情况是用户需要选择一个简历文件和一个封面来申请工作。
重要考虑因素: 这可能吗?看来很难找到一个直接的答案。 例如,像这样的工作? (我从网上的某个地方抓起来,抱歉,如果我没有记入来源) 谢谢
$ b
< form action =/ py / uploadfilemethod =postenctype =multipart / form-dataname =form1id =form1>
< label>上传文件< input type =filename =file []id =file1/>< / label>
< label>上传文件< input type =filename =file []id =file2/>< / label>
< label>上传文件< input type =filename =file []id =file3/>< / label>
< label>< input type =submitname =buttonid =buttonvalue =Submit/>< / label>
< / form>
input [type =file]
,并确保它有一个不同的名称: < form action =...>
...其他字段...
< input type =filename =coverLetter/>
< input type =filename =resume/>
...其他字段...
< input type =submitvalue =send/>
< / form>
I would have thought this would be super easy to find an answer to on the interwebs but apparently not.
On an HTML page, I wish to allow a user to select multiple files and upload them to my server. Specific context is that the user needs to choose a resume file and a cover page to apply for a job.
Important considerations:
- I'm not interested in an HTML5 or flash or tricky solution - just the basic question, is it possible with plain old HTML in a plain old browser.
- I am okay with having multiple upload fields and multiple buttons to choose each file.
- A single submit button needs to submit them both.
- Needs to support IE6.
Is this possible? It seems very hard to find a straight answer.
For example would something like this work? (I grabbed it from somewhere on the net sorry if I have not credited the source)
<form action="/py/uploadfile" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label>upload file<input type="file" name="file[]" id="file1" /></label>
<label>upload file<input type="file" name="file[]" id="file2" /></label>
<label>upload file<input type="file" name="file[]" id="file3" /></label>
<label><input type="submit" name="button" id="button" value="Submit" /></label>
</form>
thanks
Just add another input[type="file"]
, and make sure it has a different name:
<form action="...">
...other fields...
<input type="file" name="coverLetter" />
<input type="file" name="resume" />
...other fields...
<input type="submit" value="send" />
</form>
这篇关于如何在HTML表单上上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!