| | |
Convert SINGLE-file upload into multiple files with foreach loop, cant figure out
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2007
Posts: 63
Reputation:
Solved Threads: 0
Convert SINGLE-file upload into multiple files with foreach loop, cant figure out
0
#1 Oct 12th, 2008
Hello, all:
I have this single-file upload script which works great (it's a bit log cause it creates thumbs, unique ID's,e tc), 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 figure out how to integrate that.
Can anybody please help!...
See code here:
I have this single-file upload script which works great (it's a bit log cause it creates thumbs, unique ID's,e tc), 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 figure out how to integrate that.
Can anybody please help!...
See code here:
php Syntax (Toggle Plain Text)
<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>
Last edited by cscgal; Oct 12th, 2008 at 9:48 pm. Reason: Fixed code tags
![]() |
Similar Threads
- vBulletin mod_rewrite (PHP)
Other Threads in the PHP Forum
- Previous Thread: how make difference between read and unread mails.
- Next Thread: using the $ftp_server
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox chrelad class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google head href htaccess html image include insert integration ip java javascript joomla limit link list login loop mail menu methods mlm mod_rewrite multiple mysql number oop parse paypal pdf php phpmyadmin problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update upload url validation validator variable video web webdesign xml youtube





