gpt4 book ai didi

PHP创建多个目录

转载 作者:可可西里 更新时间:2023-10-31 23:57:14 24 4
gpt4 key购买 nike

比方说,在 PHP 中,我试图将图像放在根目录下的特定目录中。

我想把它放在 /images/afc/esp/stadium/ 目录下。 Images 文件夹、Federation 文件夹、Country ISO3 文件夹、content 文件夹。

$folder_full = "images/".$getFed."/".$country_folder."/stadiums";
if (!is_dir($folder_full)) mkdir($folder_full);

在你问之前,是的 $getFed$country_folder 工作并输出文本。所以,然后我得到这个错误:Warning: mkdir(): No such file or directory

我不明白?

最佳答案

您的某些子目录不存在,因此您需要迭代创建它们或将 mkdir() 的第三个参数设置为 true。请注意,第二个参数是默认为 0777 的目录权限(在 Windows 上被忽略)。

您还需要使用 /$folder_full 设置为根目录。

$folder_full = "/images/{$getFed}/{$country_folder}/stadiums";
if (!is_dir($folder_full)) mkdir($folder_full, 0777, true);

关于PHP创建多个目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13096615/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com