PHP change Folder Permissions Recursively |

Congrats, You are Subscribed to Receive Updates.

PHP change Folder Permissions Recursively

PHP change Folder Permissions Recursively. Sometime we have to change the complete folder file permissions. I mean, we may have to change all the file permissions in a directory. For that, we need to use the “chmod() ”  php function to change.  but doing it for each and every file with the following code is fuzzy work and its time consuming one.


So, we may have to use a function to this in short way.


But we have some PhP function to do this easily. but many functions failed to provide results.

function kv_change_file_permission($folder_path) {
    $kv_dir = new DirectoryIterator($folder_path);
    foreach ($kv_dir as $single) {
        chmod($single->getPathname(), 0777);
        if ($single->isDir() && !$single->isDot()) {

The above one is the function to change all the files and sub folder permissions directly.  Use the following code to call it.


That’s it, you are done.


Check the file permissions through FTP .


About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

Comment Below

Your email address will not be published. Required fields are marked *


Current ye@r *