1

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?

ЯegDwight
  • 24,821
  • 10
  • 45
  • 52
dana
  • 5,168
  • 20
  • 75
  • 116

1 Answers1

2

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>
Naren Sisodiya
  • 7,158
  • 2
  • 24
  • 35
  • nope... it doesn't solve the problem. (the little script above.) no inut field is added. – dana Apr 13 '11 at 09:59