views:

656

answers:

1

Hi,

Our PHP scripts create dynamic folders and files and we are having a permission issue. The folders were initially create using our ftpuser. EG: Album (created by ftpuser) all subfolders and files in them have to be dynamically created. The apache user is the user when a new folder is created and then it cannot write anything to that folder for some reason.

The server is running with PHP safe mode OFF.

Whenever a folder is created by php script the user is apache and the permission for some reason shows as dr----x--t

Thanks.

+2  A: 

Find the place in the PHP where the folder is created. Typically, this will be:

mkdir( folderName );

Change the line to:

mkdir( folderName, 1755 );

Or, instead, add this line after the mkdir:

chmod( folderName, 1755 );

For more information, here's the PHP mkdir documentation.

system PAUSE
changed mkdir($config->documentRoot."/images/albums/".$albumId, 777);tomkdir($config->documentRoot."/images/albums/".$albumId, 0755);It works now.
ToughPal
Cool! For completeness' sake: I missed that it needed a leading zero (0755 or 0777 instead of 777) and suggested 1755 (should have been 01755) because the '1' would make the folder "sticky" (that's the 't' at the end of 'dr----x--t'). I assumed the folder was sticky for a reason. If it doesn't need to be sticky, then no biggie.
system PAUSE