mac007 Posted October 12, 2008 Share Posted October 12, 2008 Hello, all: I have this single-file upload script which is great, but I am trying to modify it to make it do multiple files. I figured best way was to apply a foreach loop to it, but havent been able how to integrate it. Can anybody please help!... See code here: <table width="300" border="1" align="center" cellpadding="20" cellspacing="0"> <tr> <td><form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <p> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> <br /> </p> <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button> </form></td> </tr> <tr> <td height="112" align="center" valign="top"><?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $imagename = rand (). ".jpg" ; $target = "images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 750; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "images/sml_" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 110; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; //(this echo line disabled for now) echo "Large image: <img src='images/".$imagepath."'><br>"; echo "<p>Picture uploaded:<br /></p> <img src='images/sml_".$imagepath."'>"; } } ?> </td> </tr> </table> (edited by kenrbnsn to change <CODE></CODE> to tags) Link to comment https://forums.phpfreaks.com/topic/128117-help-with-this-upload-to-do-multiple-files-with-foreach-loop-cant-figure-out/ Share on other sites More sharing options...
mac007 Posted October 12, 2008 Author Share Posted October 12, 2008 I forgot to mention this upload script a bit long, cause it does a few things, like create thumbs, renames files with ramdom ID's, etc... so I want to have it done to each uploaded file, whatever number of files I decide to add to the upload form. As you'l' see, the form there just shows 1 upload field... Link to comment https://forums.phpfreaks.com/topic/128117-help-with-this-upload-to-do-multiple-files-with-foreach-loop-cant-figure-out/#findComment-663479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.