Page 1 of 1

Image compressing and resizing from Form input

Posted: Sat Aug 24, 2002 12:01 pm
by Prof Pat Pending
Hi,
I'm trying to put a compressed image into a mysql database with the following code:

$im = ImageCreateFromJPEG($src);
$src1 = ImageJPEG($im, 'firstphoto.jpg', '75');

$data = addslashes(fread(fopen($src1, "rb"), filesize($src1)));

Well, $src is the file variable retrieved from a form with a file input field. I get this message:

Warning: fopen("1","rb") - No such file or directory in c:\phpdev\www\scripts\image4.php on line 8

Warning: Supplied argument is not a valid File-Handle resource in c:\phpdev\www\scripts\image4.php on line 8

Now I can see that I'm getting a handle returned rather than data but i have looked all over th forums and can find no information on this.

All I want to do is take an image from a form, compress and resize it and put it in a db table.....but I can't.

Any ideas floating about out there?

Cheers. 8O

Posted: Sat Aug 24, 2002 12:31 pm
by volka
You're not getting a handle. Although the the manual states an int as return value in fact the gd-module code returns either RETURN_FALSE (0) or RETURN_TRUE (1) (as far as I can see).
You have to open the file again with fopen