Page 1 of 1

<***Need help creating thumbnail image upon upload***>

Posted: Fri Aug 22, 2008 12:12 pm
by grahamne
Basically this simple solution works but i need to add to it a function to create a thumbail. i have searched around and had zero luck finding anything.

<?php
session_start();
include("db.php");
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("some path". $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"profile/" . $_FILES["file"]["name"]);
$path="some path" . $_FILES["file"]["name"];
$session=$_SESSION['user'];
mysql_query("INSERT INTO some table (path, user_id)
VALUES ('$path', '$session')");
}
}
}
else
{
echo "Invalid file";
}

?>

grahamne

Re: <***Need help creating thumbnail image upon upload***>

Posted: Fri Aug 22, 2008 2:28 pm
by onion2k
grahamne wrote:Basically this simple solution works but i need to add to it a function to create a thumbail. i have searched around and had zero luck finding anything.
You searched for some thumbnail creation code and couldn't find anything? Come on.. you can't have looked very hard. It's one of the most common things there is.

This will help - http://www.google.co.uk/search?q=php+th ... s=qlH&sa=2

Re: <***Need help creating thumbnail image upon upload***>

Posted: Fri Aug 22, 2008 4:02 pm
by deejay
http://uk2.php.net/manual/en/function.imagecreate.php might be a good place to start. I think the functions are given to you in the comments on php.net somewhere.