RyanW67 Posted October 6, 2007 Share Posted October 6, 2007 I've made this single image uploader using a tutorial, basically I want to adapt so it uploaded multiple images in one go. I've seen quite a few scripts online for multi-image uploaders but I'm quite curious if what I'm trying to do is possible with this script... Here is the original code <?php if (isset($_GET['upload'])) { $folder = "../carimages/"; if ($_FILES['file']['type'] == "image/gif" || "image/jpg") { $copy = copy ($_FILES['file']['tmp_name'], "$folder/".$_FILES['file']['name']); $imagename = $_FILES['file']['name']; if (!$copy) { echo "<font face=\"Arial\" size=\"2\">Image could not be uploaded at this time, <a href=\"addform.php\">return to Admin add page</a>"; } else { echo "Image uploaded. <a href=\"index.php\">return to Admin page</a>"; echo "$imagename"; } } else { echo "Wrong file type, <a href=\"index.php\">return to Admin page</a>."; } } else { echo "<font face=\"Arial\" size=\"2\"><br /><br />If you do not need to upload a picture, you can <a href=\"index.php\">return to Admin section</a><br /><br /><b>Image Upload</b><br /><br /><form action='?upload' method='post' enctype='multipart/form-data'> <input type='file' name='file'> <input type='submit' value='Upload'> </form></font>"; } ?> And I was wondering if I did this (below) to the code, would it make it possible to upload two images at the same time: <?php if (isset($_GET['upload'])) { $folder = "../carimages/"; if ($_FILES['file']['type'] == "image/gif" || "image/jpg") if ($_FILES['file2']['type'] == "image/gif" || "image/jpg") { $copy = copy ($_FILES['file']['tmp_name'], "$folder/".$_FILES['file']['name']); $copy2 = copy ($_FILES['file2']['tmp_name'], "$folder/".$_FILES['file2']['name']); $imagename = $_FILES['file']['name']; $imagename2 = $_FILES['file']['name2']; if (!$copy) { echo "<font face=\"Arial\" size=\"2\">Image could not be uploaded at this time, <a href=\"addform.php\">return to Admin add page</a>"; } if (!$copy2) { echo "<font face=\"Arial\" size=\"2\">Image 2 could not be uploaded at this time, <a href=\"addform.php\">return to Admin add page</a>"; } else { echo "Image uploaded. <a href=\"index.php\">return to Admin page</a>"; echo "$imagename"; echo "$imagename2"; } } else { echo "Wrong file type, <a href=\"index.php\">return to Admin page</a>."; } } else { echo "<font face=\"Arial\" size=\"2\"><br /><br />If you do not need to upload a picture, you can <a href=\"index.php\">return to Admin section</a><br /><br /><b>Image Upload</b><br /><br /><form action='?upload' method='post' enctype='multipart/form-data'> <input type='file' name='file'> <input type='file' name='file2'> <input type='submit' value='Upload'> </form></font>"; } ?> I know it's a bit of a bodge attempt but am in quite a rush! Sorry about the lack of indentations, have copied it straight from my online web editor. All help appreciated Ryan Link to comment https://forums.phpfreaks.com/topic/72107-solved-multiple-image-upload/ Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 And I was wondering if I did this (below) to the code, would it make it possible to upload two images at the same time: probably, have you tried? what happened? Link to comment https://forums.phpfreaks.com/topic/72107-solved-multiple-image-upload/#findComment-363465 Share on other sites More sharing options...
RyanW67 Posted October 6, 2007 Author Share Posted October 6, 2007 Sorry - yeah I tried it, the first image would always upload but the second would not... I think what I've done wrong is somewhere in $copy = copy ($_FILES['file']['tmp_name'], "$folder/".$_FILES['file']['name']); $copy2 = copy ($_FILES['file2']['tmp_name'], "$folder/".$_FILES['file2']['name']); $imagename = $_FILES['file']['name']; $imagename2 = $_FILES['file']['name2']; Link to comment https://forums.phpfreaks.com/topic/72107-solved-multiple-image-upload/#findComment-363468 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 yeah, your vars got a little hosed: $imagename = $_FILES['file']['name']; $imagename2 = $_FILES['file2']['name']; Link to comment https://forums.phpfreaks.com/topic/72107-solved-multiple-image-upload/#findComment-363471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.