daveyah2002 Posted February 23, 2015 Share Posted February 23, 2015 Hi, I have attached a couple of files. File single.txt contains the code to upload a single selected file to a server with a random name and write the name to an SQL database. I am really just stumbling around in the dark trying to modify the code (in multiple.txt) so it will upload multiple files. The code in multiple.txt isn't falling over but it still just uploads one file and writes one filename to the database. The photo form has been modified to accept a multiple file selection and the number of selected files is indicated in the browser. input type = "file" name="photo" multiple="multiple" accept="image/* Any pointers as to where I am going wrong would be appreciated. file single.txt file multiple.txt Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 23, 2015 Share Posted February 23, 2015 Overall your code is fine in filemultiple.txt. The issue is to do with line 68 through to line 70. This is because the code will upload the first file and then it will redirect the user to photos.php after its details have been inserted into the database. You want the code to continue looping over the remaining uploaded files. To prevent this you need to move these three lines so they are not inside the for loop. So line 68 through to line 71 should read as follows } // this closes the for loop. We do want the following lines inside the loop mysqli_close($db_conx); header("location: ../photos.php?u=$log_username"); exit(); Quote Link to comment Share on other sites More sharing options...
daveyah2002 Posted February 23, 2015 Author Share Posted February 23, 2015 WooHoo! Ch0cu3r. Thanks so much it's working now with that change. Quote Link to comment 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.