简体   繁体   English

将使用 imagejpeg 创建的图像添加到使用 mkdir php 创建的目录

[英]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.我知道我说$folderName 的方式。 $file_name is wrong. $file_name是错误的。 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().如果您想创建整个路径 - 只需在 mkdir() 中将第三个参数作为 true 传递。 also in the imagejpeg() pass the complete directory也在 imagejpeg() 中传递完整的目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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