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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
grahamne
Forum Newbie
Posts: 6
Joined: Mon Jun 16, 2008 2:29 pm

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

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

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

Post 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
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

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

Post 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.
Post Reply