[英]Permission denied Php script
The Php code creates nested directories and sets them permissions: Php代码创建嵌套目录并为其设置权限:
$pathToFile = 'public/loaded/' . $category . date('/Y/m/d/H/i/');
$pathToFile = str_replace('//', '/', $pathToFile);
if(!file_exists($pathToFile)){
mkdir($pathToFile, 0775, true);
}
chmod( $pathToFile, 0775);
Result of this action is : 该操作的结果是:
Message: mkdir(): Permission denied Message: chmod(): No such file or directory
消息:mkdir():权限被拒绝消息:chmod():没有此类文件或目录
In terminal Ubuntu i tried change permission on root directory /public : 在终端Ubuntu中,我尝试了对根目录/ public的更改权限:
chmod -R ug+rw /public
chmod -R ug + rw / public
But this command helped, so, what permission must be on folder where loads all users images and documents? 但是此命令有所帮助,因此,在其中加载所有用户图像和文档的文件夹上必须具有什么权限?
chmod 777 -R public
chmod 777 -R公共
mkdir()
requires a full path, not a relative one. mkdir()
需要完整路径,而不是相对路径。
Try this instead: 尝试以下方法:
$pathToFile = $_SERVER['DOCUMENT_ROOT'] . '/public/loaded/' . $category . date('/Y/m/d/H/i/');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.