View Full Version : Folder Permissions

07-28-2012, 10:59 PM
I am having trouble implementing code for setting "Access All" on the folder permissions for my web folder.
I've tried a number of lines of code but I can't seem to get it right. I am running a script install.php from a test folder

like so:

I want to make /test/ 0777 permission, and it currently is set at 0755

I've tried

$FullPath = $_SERVER['DOCUMENT_ROOT']. '/Test';
echo $FullPath;
chmod($FullPath, 0777) or die ("Permission not granted for root");


$FullPath = '../Test';

and just plain setting the chmod as 0777 (no mkdir)... its got me stumpped and banging my head!

I have set perrimisions on this webserver before, so I can't understand why it refuses to work. In those cases I created folders first and then set the chmod, as I have a server that doesn't allow direct setting of mkdir permission, for whatever reason (which reminds me the webserver is linix based). The only thing I can think of is that some how you can't set permission of folder you are in?

Going crazy ... and thanks in advance

07-29-2012, 12:31 AM
Here's some code from one of my pages.

if ((!file_exists($_SESSION["path"]))&&($_FILES['userfile']['name'] != "" ))
die('You cannot upload to the specified directory, please CHMOD it to 777.');
You can't apply chmod to the whole path, only to the directory, without the end slash. 'my_path' in the above code is the whole path.