[英]Warning: mkdir(): Permission denied in hostinger
I was trying to create directories automatically with php, with the mkdir() function.我试图用 php 和 mkdir() function 自动创建目录。
<?php
session_start();
$domain = $_SESSION['domain'];
$mydomain = "/" . $domain;
echo $_SESSION['domain'] . " " . $mydomain . "<br />";
$mk = mkdir($mydomain, 0777, true);
if ($mk){
echo "directory created";
}else{
echo "directory no created";
}
?>
but it gave me back this error但它给了我这个错误
[02-May-2021 09:19:41 UTC] PHP Warning: mkdir(): Permission denied in /home/u950517783/domains/mydomain.host/public_html/website/createdir.php on line 7
[02-May-2021 09:22:28 UTC] PHP Warning: mkdir(): Permission denied in /home/u950517783/domains/mydomain.host/public_html/website/createdir.php on line 7
[02-May-2021 09:22:30 UTC] PHP Warning: mkdir(): Permission denied in /home/u950517783/domains/mydomain.host/public_html/website/createdir.php on line 7
[02-May-2021 09:22:31 UTC] PHP Warning: mkdir(): Permission denied in /home/u950517783/domains/mydomain.host/public_html/website/createdir.php on line 7
[02-May-2021 09:22:32 UTC] PHP Warning: mkdir(): Permission denied in /home/u950517783/domains/mydomain.host/public_html/website/createdir.php on line 7
[02-May-2021 09:22:32 UTC] PHP Warning: mkdir(): Permission denied in /home/u950517783/domains/mydomain.host/public_html/website/createdir.php on line 7
[02-May-2021 09:22:36 UTC] PHP Warning: mkdir(): Permission denied in /home/u950517783/domains/mydomain.host/public_html/website/createdir.php on line 7
how can i fix that?我该如何解决? im using hostinger
我正在使用托管程序
You can try like below您可以尝试如下
<?php
session_start();
$domain = $_SESSION['domain'];
$mydomain = "/" . $domain;
echo $_SESSION['domain'] . " " . $mydomain . "<br />";
$old = umask(0);
$mk = mkdir($mydomain, 0777, true);
umask($old);
if ($mk){
echo "directory created";
}else{
chmod($mydomain, 0777);
}
?>
if mkdir()
Not worked, You need to change permissions using chmod()
如果
mkdir()
不起作用,您需要使用chmod()
更改权限
Use echo
for example to look at the value of $mydomain
and then use this command to give the right access例如,使用
echo
查看$mydomain
的值,然后使用此命令授予正确的访问权限
chmod 777 -R <directory name>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.