PHP: mkdir(): Permission denied
13,391
Check out php's mkdir.
You'll need to set recursive to true, so try something like mkdir($dir,0700,true)
Related videos on Youtube
Author by
teslasimus
Updated on September 18, 2022Comments
-
teslasimus over 1 year
I've php script that should create two new folders in "albums" and "pl". in "albums" apache can create a new folder but not in "pl", even though they have the same permissions. I can't understand what I'm doing wrong.
ls -Z /music drwxrwxrwx. apache root system_u:object_r:unlabeled_t:s0 albums drwxrwxrwx. apache root system_u:object_r:unlabeled_t:s0 pl
php
function createdir($dir) { if (!is_dir($dir)) { mkdir($dir); if (is_dir($dir)) { echo "PASS<br />"; }else{ echo "FAILED<br />"; } }else{ echo "The dir is there"; } } createdir("/music/pl/07012013/"); createdir("/music/albums/06012013333333331111/");
su apache
su - apache -s /bin/bash -bash-4.1$ mkdir /music/pl/06012013 mkdir: cannot create directory `/music/pl/06012013': Permission denied
-
u8sand over 11 yearshow about trying to run as apache and try to make a directory (via commandline). 'su apache' That way you can get better error response and diagnose the permissions issue you may have.
-
Jorge Orpinel Pérez almost 6 yearsThe user running the apache service probably doesn't have the right permissions.
-
-
teslasimus over 11 yearsdidn't work ...