Search code examples
phplinuxcpanelmkdir

PHP mkdir Permissions


I have tried the following but it seems the folder gets created on the server (cPanel Linux) as 755 and not 777 why? and how could I make it write permission 777

mkdir($location.$folderName, 0777);
mkdir($location.$folderName, 777);

Solution

  • Try

    chmod($location.$folderName, 0777);
    

    Please see http://php.net/manual/en/function.chmod.php for more examples and documentation in changing file mode

    If you are still having problem ... sometimes you need to change ownership

     chown($location.$folderName, "root");
    

    Please see http://www.php.net/manual/en/function.chown.php for documentation