dan_t Posted July 11, 2010 Share Posted July 11, 2010 Hi all, How would I go about entering multiple photo's and then the first and last name and email address from a from. if (!isset($_GET['subpage'])) { // Image Upload Form Below ?> <form method="post" action="addphoto.php?subpage=upload" enctype="multipart/form-data"> Photo1:<br /> <input type="file" name="imagefile" class="form"> <br /><br /> Photo2:<br /> <input type="file" name="imagefile" class="form"> <br /><br /> <input name="submit" type="submit" value="Submit" class="form"> <input type="reset" value="Clear" class="form"> </form> <?php } else if (isset($_GET['subpage']) && $_GET['subpage'] == 'upload') { // Uploading/Resizing Script $url = $_FILES['imagefile']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") On this one image works, I added another input, but don't know how to add a second file to the $_FILES['imagefile']['name']; part. Quote Link to comment Share on other sites More sharing options...
xcasio Posted July 11, 2010 Share Posted July 11, 2010 Hi, Just change the name of the file inputs into name="imagefile[]". Afterwards, when processing it in PHP, treat $_FILES['imagefile']['name'] as an array. Quote Link to comment Share on other sites More sharing options...
BizLab Posted July 11, 2010 Share Posted July 11, 2010 Hi, Just change the name of the file inputs into name="imagefile[]". Afterwards, when processing it in PHP, treat $_FILES['imagefile']['name'] as an array. To clarify: foreach($_FILES['imagefile'] as $file){ $file_name = basename($file['name']); // and here would be your file name - basename is good practice $errors = $file['error']; // any errors on upload $image_temp = $file['tmp_name']; //this is the temp name/address of the actual uploaded file $image_type = $file['type']; // this is the file type (jpeg, png, pdf, ect...) move_uploaded_file($image_temp, $destination.$file_name); @unlink($image_temp); // don't forget to delete the temp image } That should pretty much do it for you 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.