Resize Image then Upload to Server Directory
Posted: Sun Aug 16, 2009 12:36 pm
Hi.
I have a web page that uploads images (one by one) to a directory on the web server.
Trouble is, people could upload 2mp images and that is way too big for the site to display; it needs to be only 700 pixels wide, or 800 tops!
I have found a few scripts that do resizing, but none that appear to be straight forward, or that will work with an "upload" script.
My upload script is:
With the $random system that renames files, I can't see how to plug in a resizer. The other problems is that many of the resizers are for JPG only. Some photos could easily be PNG or GIFs, depending on the camera used.
Can anyone please help?
I have a web page that uploads images (one by one) to a directory on the web server.
Trouble is, people could upload 2mp images and that is way too big for the site to display; it needs to be only 700 pixels wide, or 800 tops!
I have found a few scripts that do resizing, but none that appear to be straight forward, or that will work with an "upload" script.
My upload script is:
Code: Select all
$photo=$_POST['photo'];
$pic=($_FILES['photo']['name']);
$target = $_SERVER['DOCUMENT_ROOT']."/images/productphotos/";
srand(time());
$random = (rand()%99999999);
$pic=($_FILES['photo']['name']);
$newname="$random"."$pic";
$target = $target . $newname;
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
echo "happy days";
}Can anyone please help?