Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving files to sub directory with imagejpeg

Tags:

php

image

I have a php file that creates a thumbnail using an uploaded image. If i use

imagejpeg( $tmp_img, $_FILES["file"]["name"] );

it saves the picture without any issues to the same directory that the upload.php file is in.

I want to save the picture to

imagejpeg( $tmp_img, "uploads/thumbnails/" + $_FILES["file"]["name"] );

where the uploads folder is in the same directory as the upload.php file. But this doesnt seem to work... where have i gone wrong?

like image 839
Innercynic Avatar asked Dec 21 '22 06:12

Innercynic


1 Answers

You need to use the . in place of + in:

imagejpeg( $tmp_img, "uploads/thumbnails/" + $_FILES["file"]["name"] );
                                           ^

. is the string concatenation operator in PHP.

like image 55
codaddict Avatar answered Dec 24 '22 01:12

codaddict