graham23s Posted August 30, 2007 Share Posted August 30, 2007 Hi Guys, i have a screen with a drop down selection box, 1-5, the user can select how many files they want to upload, depending on what they select THAT number of input boxes are displayed for them to upload, besides each i have a hidden field which stores the number of uploads they chose: like: <?php ## how many nfos ######################################################## for($n=0; $n < $needednfos; $n++) { echo '<input type="hidden" name="need_nfo" value="'.$needednfos.'"><input type="file" name="nfo[]"><br />'; } ?> </td> </tr> <tr> <td align="right" /><b>RAR/ZIP</b></td><td align="left"> <?php for($i=0; $i < $uploadsneeded; $i++){ echo '<input type="hidden" name="need_nzb" value="'.$uploadsneeded.'"><input type="file" name="nzb[]" ><br />'; } ?> the part im not sure about is how to go about inserting all the uploaded files into mysql and moving them all, surely i dont need to write the whole upload code for every fields , i take it some kind of loop is needed just not sure how to start it any input would be appreciated Graham Quote Link to comment https://forums.phpfreaks.com/topic/67298-solved-multi-uploading-files-question/ Share on other sites More sharing options...
MadTechie Posted August 30, 2007 Share Posted August 30, 2007 simple script, http://www.phpfreaks.com/forums/index.php/topic,156653.msg681151.html#msg681151 Quote Link to comment https://forums.phpfreaks.com/topic/67298-solved-multi-uploading-files-question/#findComment-337647 Share on other sites More sharing options...
graham23s Posted August 30, 2007 Author Share Posted August 30, 2007 Hi MT, Thanks for the link, i can't see the code once the uploads are selected and the submit button is pressed, have i missed it there? thanks mate Graham Quote Link to comment https://forums.phpfreaks.com/topic/67298-solved-multi-uploading-files-question/#findComment-337651 Share on other sites More sharing options...
MadTechie Posted August 30, 2007 Share Posted August 30, 2007 OK heres a basic example <form method="post" enctype="multipart/form-data" > <input name="images[]" type="file" /><br /> <input name="images[]" type="file" /><br /> <input name="images[]" type="file" /><br /> <input name="submit" type="submit" value="sumit" /> </form> <?php upload(); function upload() { if( isset($_FILES) ) { foreach($_FILES['images']['name'] as $K => $V) { if(!empty($V)) { $target_path = "uploads/"; $target_path = $target_path . basename($V); if(@move_uploaded_file($_FILES['images']['tmp_name'][$K], $target_path)) { echo "The file ".basename($V)." has been uploaded<br />"; } else{ echo "There was an error uploading the file '".basename($V)."', please try again!<br />"; } } } } } ?> NOTE: remove the @ from "@move_uploaded_file" if you have problems (it will show the error) Quote Link to comment https://forums.phpfreaks.com/topic/67298-solved-multi-uploading-files-question/#findComment-337666 Share on other sites More sharing options...
graham23s Posted August 30, 2007 Author Share Posted August 30, 2007 thanks MT i know where to go now:) cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/67298-solved-multi-uploading-files-question/#findComment-337671 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.