如何在HTML表单上上传多个文件 [英] How to upload multiple files on an HTML form

查看:87
本文介绍了如何在HTML表单上上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在一个HTML页面上,我希望允许一个用户选择多个文件并将其上传到我的服务器。具体情况是用户需要选择一个简历文件和一个封面来申请工作。



重要考虑因素:


  • 我对HTML5或Flash不感兴趣或棘手的解决方案 - 只是基本的问题,是在一个普通的旧浏览器中使用普通的旧HTML的可能。

  • 我有多个上传字段和多个按钮来选择每个文件。 / li>


  • 需要支持IE6。
    $ 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表单上上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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