gpt4 book ai didi

php创建目录

转载 作者:行者123 更新时间:2023-12-02 06:39:48 25 4
gpt4 key购买 nike

我正在创建一个目录,但出现错误

警告:chmod() [function.chmod]:第 104 行/home/www/public_html/console/pubs-add.php 中没有这样的文件或目录

运行代码的 php 文件位于 www/console 中,我尝试创建的目录位于 www/images/gallery 中。

我已经尝试了多种设置路径的变体,例如 ../images/gallery 或 home/www,但似乎都不起作用

define("PATH", "/www/images/gallery");

$dir = 'a1234';

$targetfilename = PATH . '/' . $dir;

if (!is_file($dir) && !is_dir($dir)) {
mkdir($dir); //create the directory
chmod($targetfilename, 0777); //make it writable
}

最佳答案

您的 mkdir 命令只使用 $dir,它只是 'a1234'(在当前工作目录中)。这将失败(并使 chmod 也失败)。

解决方案:您可能希望在 $dir 前加上 PATH...

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

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