andymike07 Posted December 25, 2007 Share Posted December 25, 2007 I'm writing a script that allows user's to upload an unknown number of files to the server. I've set the form up so it has one file upload field, named file1, by default. If the user wants has another file to upload they simply click an "Add Upload Field." link that uses javascript to add another file upload field. Each new field the user adds is named "file2", "file3", "file4", etc... Is there an easy way to use PHP to find the data for the fields added with Javascript so I can access them with my script? Quote Link to comment https://forums.phpfreaks.com/topic/83165-php-form-help/ Share on other sites More sharing options...
cooldude832 Posted December 25, 2007 Share Posted December 25, 2007 yes change your upload adding scheme naming from <input type="file" name="file1" /> <input type="file" name="file2" /> <input type="file" name="file3" /> etc to <input type="file" name="file[1]" /> <input type="file" name="file[2]" /> etc. Then say <?php foreach($_FILES['file'] as $key => $value){ //Handle uploads } ?> Quote Link to comment https://forums.phpfreaks.com/topic/83165-php-form-help/#findComment-423025 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.