mkdir(): Permission denied

Asked

Viewed 1,677 times

0

I’m trying to create a directory by PHP on my local Linux server, but I’m not getting it. It gives the following error:

mkdir(): Permission denied...

I’ve tried the following codes:

if(!file_exists($diretorio)){
          mkdir("/../../".$ano,0777,true);
 }

and that too:

if(!file_exists($diretorio)){
          mkdir("/../../".$ano);
          chmod("../../".$ano,0777);
 }

and by consciousness-raising:

if(!file_exists($diretorio)){
          mkdir("/../../".$ano,0777,true);
          chmod("../../".$ano,0777);
 }

but all return that error. The root directory is allowed 777. Does anyone know how to fix this?

  • The root directory may be with permission 777 but if the directory you are trying to create the new directory does not have permission, there is no way. Example: /var/www you have the permission 777 but /var/www/public_html/ not allowed to record, you will not be able to create the directory, but gets inside the directory www.

  • Hello wmsouza. Only I had already given permission in the directory where the files are and where I want to create the directory with the command sudo chmod -R 777 'nome do diretorio' and have confirmed with the command ls -l and the permission is as 777.

  • So look at that answer: Linux server permissions issues.

  • Try running the "setenforce 0" command on the terminal

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.