You are here:Home»KB»Programming»PHP»Reset permissions recursively via PHP
Friday, 26 February 2010 00:00

Reset permissions recursively via PHP

Written by

You can reset file permissions via PHP. the code below is an example on resetting file permission recursively. You must have shell_exec enabled.


  • Create a blank php file
  • Add the following code to it
    <?php
      echo shell_exec( 'find . -type f -print0 | xargs -0 chmod 644' );
      echo shell_exec( 'find . -type d -print0 | xargs -0 chmod 755' );
    ?>
  • Place the file in the root directory you want it to work from
  • go to your webbrowser and execute the file
Read 702 times Last modified on Wednesday, 12 November 2014 23:12