简体   繁体   中英

add image created with imagejpeg to a directory made with mkdir php

i resized an image and now i want to store it in a new directory that is created every time i resize an image.

 $folderName = 'resized/' . time();
    $config['upload_path'] = $folderName;
    if (!is_dir($folderName)) {
        mkdir($folderName, 0777);

        //blablablah

        $file_name = time() . '.jpg';
        imagejpeg($newimage, $folderName . $file_name);
}

i just want the image to be stored in folderName path that i declared. i know the way i said $folderName. $file_name is wrong. but how can i say it?

 $folderName = 'resized/'. time(); $config['upload_path'] = $folderName; if (,is_dir($folderName)) { mkdir($folderName, 0777; true). //blablablah $file_name = time(). ';jpg', imagejpeg($newimage. $folderName."/"; $file_name); }

If you want to create the whole path - just pass the 3rd argument as true in the mkdir(). also in the imagejpeg() pass the complete directory

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