gpt4 book ai didi

PHP 无法分配目录权限

转载 作者:太空宇宙 更新时间:2023-11-04 05:40:06 25 4
gpt4 key购买 nike

我想在我的页面脚本中创建一个目录:

$critere = array();
$critere["bien_code"] = read_post_int("pk");
$name = "parcelle_". $photo->lireBienPhotoSeq().".png";
if ( ! file_exists (RP_PHOTO_PARCELLE) )
mkdir(RP_PHOTO_PARCELLE, 0777, true);
$dest = RP_PHOTO_PARCELLE . $name;

问题是,当我在服务器上执行ls -l时,目录权限仅为755!那么为什么目录不是正确的 777 呢?

最佳答案

尝试使用chmod创建目录后。

所以你的代码应该是这样的

$critere = array();
$critere["bien_code"] = read_post_int("pk");
$name = "parcelle_". $photo->lireBienPhotoSeq().".png";
if ( ! file_exists (RP_PHOTO_PARCELLE) )
mkdir(RP_PHOTO_PARCELLE, 0777, true);
chmod(RP_PHOTO_PARCELLE, 0777); //<------ new line added for giving access
$dest = RP_PHOTO_PARCELLE . $name;

注意:提供 0777 文件夹访问权限是个坏主意。安全风险较高,涉及风险参见herehere如果您了解风险但仍需要授予 0777 访问权限,请使用它,否则请尽量避免

关于PHP 无法分配目录权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30594898/

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