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
<***Need help creating thumbnail image upon upload***>
Moderator: General Moderators
Re: <***Need help creating thumbnail image upon upload***>
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.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.
This will help - http://www.google.co.uk/search?q=php+th ... s=qlH&sa=2
Re: <***Need help creating thumbnail image upon upload***>
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.