note 75639 deleted from function.move-uploaded-file by bjori
| From: | bjori@php.net | Date: | Sun, 10 Jun 2007 15:21:08 +0000 |
| Subject: | note 75639 deleted from function.move-uploaded-file by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127355@lists.php.net to get a copy of this message | ||
Note Submitter: info at biawebdesign dot com
Reason: useless
----
Hi guys this is my 1st post here. Trying to upload up to 8 images at once i spent some time figuring
out how to do it. So if anyone will need how I handled that issue here it is:
<?php
$someuniq = date("Hms");
/// INSERT whatever text fields you have there:
$imprd="INSERT INTO somegallery
(gtitle, guniq, etc)
VALUES
('$gtitle', '$someuniq ', '$etc')";
if (!mysql_query($imprd)) {echo mysql_error();}
//// UPDATE SQL with image name so you can output in HTML when you need
//number 8 = how many img fileds, each img field is img0,img1...etc
//$fullpath = 'somefolder/';
for($i = 0; $i < 8; $i++)
{
$tmp_name = $_FILES["img".$i]["tmp_name"];
$new_name = $_FILES["img".$i]["name"];
$clean_name = ereg_replace("[^a-z0-9._]", "", str_replace(" ",
"_", str_replace("%20", "_", strtolower($new_name) ) ) );
move_uploaded_file($tmp_name,$fullpath . $clean_name);
$imgz= "img".$i;
if (strlen($clean_name) > 2)
{
$imep3="UPDATE somegallery SET
$imgz = '$clean_name'
WHERE someuniq = '$someuniq'";
if (!mysql_query($imep3)) {echo mysql_error();}
}
}
?>