include("../components/hzi_connection.php"); ?>
if($_POST)
{
if(($_FILES["image"]["error"] == "") &&($_FILES["image"]["type"] == "image/jpeg"))
{
// Image entry
list($width, $height) = getimagesize($_FILES["image"]["tmp_name"]);
$wtoh = $width/$height;
// Database entry
hzi_mysql_connect();
$sql = 'INSERT INTO `photos` (`ID`, `dateadded`, `desc`) VALUES (\'\', \'' . time() . '\', \'' . $_POST['desc'] . '\')';
$result = mysql_query($sql)
or die("MySQL error: " . mysql_error());
$IDadded = mysql_insert_id();
// Create Blank Images
$img = imagecreatetruecolor(488,(int)488/$wtoh);
$source = imagecreatefromjpeg($_FILES['image']['tmp_name']);
//Set up destinations
$imgdest = "../pictures/main.jpg";
//Make Images
imagecopyresampled($img, $source ,0, 0, 0, 0, 488, (int)488/$wtoh, $width, $height);
imagejpeg($img,$imgdest);
// Debugging Output
echo "Main image uploaded.";
//echo "Image proportions: Width: " . $width . ", Height: " . $height . " "; //echo $thumbdest . " "; //echo $imgdest . " "; hzi_mysql_close(); } else { echo "Error: " . $_FILES["image"]["error"] . " "; echo "Upload: " . $_FILES["image"]["name"] . " "; echo "Type: " . $_FILES["image"]["type"] . " "; echo "Size: " . ($_FILES["image"]["size"] / 1024) . " Kb "; echo "Stored in: " . $_FILES["image"]["tmp_name"]; } } else { ?> } ?> |
||