Reputation: 5228
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?
Upvotes: 1
Views: 13954
Reputation: 7288
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>
Upvotes: 2