Hello I need some help with these image hosting I'm trying to add multiple upload files options but I'm having trouble changing the code from single upload to various uploads, the outcome file index2.php has the code for the first usefile, i'm not sure if how to go about, i tried adding for a usefile1 and userfile2 but that doesn't work, any ideas, help. is greatly appreciated
Look at the Uploading File Arrays section here: http://www.php.net/manual/en/features.file-upload.php If you need more specific help, you may need to post code samples of the HTML FORM you are using and how you are trying to parse it and what exactly is happening.
Yes the PHP guide is the way to go. If you know your way around PHP its quite simple you have to set the name of the variable your sending as an array such as files[] then you can do what you normally do with your files but remember they are now in an array so you will need to separate an process each one individually.
thanks to all for the help, i've been trying things out but im having a complication since my code looks like this <form method="post" enctype="multipart/form-data" action="reg/index2.php"> <INPUT TYPE="file" NAME="userfile[]" size="27" /> <INPUT TYPE="file" NAME="userfile[]" size="27" /> <INPUT TYPE="file" NAME="userfile[]" size="27" /> <input type="submit" value="Upload" name="upload"/> </form> so I have to sort things out on the index2.php and I'm not sure how to go about to add the foreach code so that it works, any ideas?
on the index2.php it starts like this <? include "config.php"; if (!isset($HTTP_POST_FILES['userfile'])) exit; if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; } if(($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/JPEG") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) { if (file_exists("./".$path . $HTTP_POST_FILES['userfile']['name'])) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; } //generate random number $zufall = rand(1,9999); $fupl = "$zufall"; keeps going with code to show the pictures
That's the problem right there. The code sample is assuming there is only 1 entry in the $HTTP_POST_FILES[] array. Look at the sample on php.net again. It uses a foreach statement to loop through each entry in the array. You will have to do it that way to be able to get to each different file that was uploaded. Hope that helps.