Forum Moderators: coopster

Message Too Old, No Replies

image upload and thumbnail

         

MWpro

1:43 pm on Nov 26, 2003 (gmt 0)

10+ Year Member



I'm trying to make a script that will allow the user to upload a picture through a form, save the picture onto the server, and automatically create a thumbnail of the picture and save it as a different file.

I am able to get the picture uploaded, I just need some help with the thumbnail part. Here's what I have so far. (The database part is used to store how many images are in there so the next file name can be figured out.)

(php)



<?
if(isset($submit)){
if (is_uploaded_file($_FILES['upfile']['tmp_name'])){

$result=mysql_query("SELECT * FROM images");
$id=mysql_num_rows($result);
$id++;
$file_realname = "image".$id.".gif";

copy($_FILES['upfile']['tmp_name'], "/usr/www/etc/img/uploads/$file_realname");

$q = "INSERT INTO images (id, file) VALUES ('', '$file_realname')";
mysql_query($q);

echo "$upfile_name uploaded successfully.";

} else {
echo "No file uploaded";
}

}
?>


Birdman

2:02 pm on Nov 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello, I wrote a script thumbnail script [webmasterworld.com] awhile back. It also uses mySQL, but you can, at least, get the resize and thumbnail generation part. I picked it up from php.net/image

Good luck! When implemented, it a very nice tool.