note 99467 deleted from features.file-upload.multiple by danbrown
| From: | danbrown@php.net | Date: | Thu, 19 Aug 2010 15:17:02 +0000 |
| Subject: | note 99467 deleted from features.file-upload.multiple by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171856@lists.php.net to get a copy of this message | ||
Note Submitter: jh_1205 at yahoo dot com
----
<?php
if($_POST["submit"]=='Add' AND $_POST["name"]!='')
{
$con = mysql_connect("localhost","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
for($i=0; $i < count($_FILES['image']['tmp_name']);$i++)
{
if((!empty($_FILES["image"])) &&
($_FILES['image']['error'] == 0))
{
$current_image=$_FILES['image']['name'][$i];
$extension = substr(strrchr($current_image, '.'), 1);
if (($extension!= "jpg") && ($extension != "jpeg"))
{
die('Unknown extension');
}
$time = date("fYhis");
$new_image = $time . "." . $extension;
$image=$new_image;
$destination="C:/xampp/htdocs/bicol/gallery/".$new_image;
$action = copy($_FILES['image']['tmp_name'][$i], $destination);
$destination="gallery/".$new_image;
$action = copy($_FILES['image']['tmp_name'][$i],$destination);
mysql_select_db("blog", $con);
@mysql_select_db(blog) or die( "Unable to select database");
$sql="INSERT INTO gallery (name,description,photo,postdate)
VALUES('$_POST[name]','$_POST[msg]','$image',curdate())";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
}
else
{
mysql_select_db("blog", $con);
@mysql_select_db(blog) or die( "Unable to select database");
mysql_select_db("blog", $con);
@mysql_select_db(blog) or die( "Unable to select database");
$sql="INSERT INTO gallery (name,description,photo,postdate)
VALUES('$_POST[name]','$_POST[msg]','$image',curdate())";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$id=$id + 1;
}
}
?>
<script>document.location="index.php"</script>
<?
}
?>