okay guys, this is an emergency! if someone could help me on this one, it would be awesome!!
so, my problem is that I upload images to the webserver via a html form, and before the images are saved, they are resized to the width 410. so far so good.
but! if I add large resolution images, like 1600x1200 px, I get a fatal error saying that there’s not enough memory, but it works for images that are 640x480 pixels. I checked how much memory I have allocated on my webserver account, and it’s 8mb.
I have been thinking: if I could use the already uploaded image $_FILES[‘image’][‘tmp_name’] that (I think) already is allocated in the servers memory, I wouldn’t have to use the function imageCreateFromJPEG($tmp_file);
but how am I supposed to achieve that??
here’s the code:
$file = $_FILES['image']['name'];
$tmp_file = $_FILES['image']['tmp_name'];
$ext = strstr($file,".");
$ext = strtolower($ext);
if($ext != ".jpg" && $ext != ".jpeg") {
echo("You can only upload JPEG files.");
} else {
$t_wd = 410;
$o_im = imageCreateFromJPEG($tmp_file);
imagesx($o_im);
imagesy($o_im);
$t_ht = round($o_ht * $t_wd / $o_wd);
$t_im = imageCreateTrueColor($t_wd,$t_ht);
#imageCopyResized($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
imageJPEG($t_im,"../images/".$file);
imageDestroy($o_im);
imageDestroy($t_im);
Thank you so much in advance!