[eluser]TheFuzzy0ne[/eluser]
Is your form a multipart form?
I still think you'll make it much easier using <input type=“file” name=“userfile” multiple=”“ />. It has the following benefits:
* It saves you from writing Javascript
* It allows users to select multiple files to upload by holding CTRL whilst clicking.
* The user doesn't have to figure out how many files they want to upload in advance. What happens if I think I have 9 images to upload, and then, after setting up each file upload, I realise it's actually 10? Won't your script add another 10 input fields, and also cause duplicate field names?
If you insist on doing it your way, you'd be much better off using an array for the file uploads. Then the server will know exactly how many files there are, and your Javascript doesn't even need to know how many upload fields there are. It can just happily append more.
Personally, I've never been keen on non-degradable Javascript, and I don't see the point in making your life more difficult than it needs to be. Sorry...