用于动态上传多个文件的jQuery解决方案 [英] jQuery solution for dynamically uploading multiple files

查看:129
本文介绍了用于动态上传多个文件的jQuery解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表格可以上传照片。我不知道我可以在特定时间上传多少张照片。是否有任何jQuery / AJAX解决方案用于在表单中动态添加文件上传字段?

I have a form in which I am uploading pictures. I don't know how many pictures I may upload at a specific time. Are there any jQuery/AJAX solutions for dynamically adding a file upload field in a form?

推荐答案

添加文件字段的简单代码在表单中使用jQuery

simple code for adding a file field in form using jQuery

<form id="myForm" action="your-action">

    <input type="file" name="files[]" />

    <a href="#" onclick="addMoreFiles()">Add More</a>

</form>

<script>
       function addMoreFiles(){

           $("#myForm").append('<input type="file" name="files[]" />')
       }

 </script>

这篇关于用于动态上传多个文件的jQuery解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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