I couldn't find a lot ofhelp with this since I'm not saving any of the imaages in directories, only in a mysql DB. I'm trying to create (and then save, but I know how to do the saving part) a thumbnail version of a user uploaded image, along with the original. I think my problem is just due to my lack of understanding of the imagecopyresized function, since that is the error I'm getting.
A quick note: I do not have access to all GD functions, which is why I'm trying to use just the imagecreate and imagecopyresized functions that are available to me. My host is pretty worthless so trying to get the full library compiled is not an option right now.
Here's the relevant code:
if ($_FILES) {
$image_types = Array ("image/bmp",
"image/jpeg",
"image/pjpeg",
"image/gif");
if (is_uploaded_file ($_FILES['userfile']['tmp_name'])) {
$userfile = addslashes (fread
(fopen ($_FILES['userfile']['tmp_name'], "r"),
filesize ($_FILES['userfile']['tmp_name'])));
$image_size = getimagesize($_FILES['userfile']['tmp_name']);
$image_width = $image_size[0];
$image_height = $image_size[1];
$file_name = $_FILES['userfile']['name'];
$file_size = $_FILES['userfile']['size'];
$file_type = $_FILES['userfile']['type'];
$max_thumbx = 90;
$max_thumby = 90;
$thumbx = 0;
$thumby = 0;
if ($image_width>$image_height) {$thumbx=$max_thumbx;$thumby=$maxy;};
if ($image_height>$image_width) {$thumbx=$max_thumby;$thumby=$maxx;};
$thumb = imagecreate($thumbx, $thumby);
imagecopyresized($thumb, $_FILES['userfile']['name'],0,0,0,0,$thumbx, $thumby, $image_width, $image_height);
$thumbfile = addslashes (fread
(fopen ($thumb, "r"),
filesize ($thumb)));
$thumb_size = getimagesize($thumb);
$thumb_width = $thumb_size[0];
$thumb_height = $thumb_size[1];
$thumb_name = $file_name;
//Might need to fix these two
$thumb_size = $thumb[2];
$thumb_type = $thumb[3];
//...followed by inserting into the DB
I know that I'm not using imagecopyresized properly, and I'm hoping that someone will be able to easily tell me how to fix it. If there isn't some easy solution to this, then a push in the right direction towards what might help would be equally helpful.
If any other information is necessary, please ask. Thanks in advance.