简体   繁体   中英

Saving files to sub directory with imagejpeg

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?

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

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

. is the string concatenation operator in PHP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM