You often ran into a position where you need to deploy your script on hosting and you have only ftp access. Your web server configuration may need to have right permissions on files to execute them.
Normally on linux servers directory permissions are set to 0755 and file permissions are 644, but if security is configured with apache it may require 0755 permissions on the files as well.
To change file permissions using ftp is a hectic job, it takes too much time to change permissions.
There is a simple solution in PHP. Just create a permissions file write the following code in it and put it in root directory and run the file, it will change all the files/directory permissions recursively with ease.
Create a file “chmod.php” and then put it in root directory.
<?php //chmod.php function chmod_r($path, $perm) { $dir = new DirectoryIterator($path); foreach ($dir as $item) { chmod($item->getPathname(), 0755); if ($item->isDir() && !$item->isDot()) { chmod_r($item->getPathname()); } } } //chdir(".."); $path = getcwd(); //$path = "rental"; chmod_r($path, 0755); echo "Permissions changed.";
run that file in your browser like
http://example.com/chmod.php
It will change all files/directories permissions.
Recent Comments