<***Need help creating thumbnail image upon upload***>
Posted: Fri Aug 22, 2008 12:12 pm
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
<?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