note 40786 added to function.ftp-chmod
| From: | tenphp at hallvord dot com | Date: | Sun, 14 Mar 2004 21:58:26 +0000 |
| Subject: | note 40786 added to function.ftp-chmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66835@lists.php.net to get a copy of this message | ||
I needed to do a recursive chmod on a set of folders, subfolders and files on a server where I have
a hosting account without any shell access. This function helps. Call it with the connection as the
first parameter and the folder to start from as the second. Not exactly fast (you probably want to
include a set_time_limit() to avoid a timeout.)
<?php
function recursive_chmod_with_ftp($connection, $basefolder){
$files = ftp_nlist($connection,$basefolder); //get files in directory
foreach ($files as $file) {
$isfile = ftp_size($connection, $file);
if($isfile == "-1") { //Is a file or a folder?
ftp_site ( $connection, 'CHMOD 777 '.$file);
recursive_chmod_with_ftp($connection, $file); // a folder! Keep going down!
}else {
ftp_site ( $connection, "CHMOD 777 '.$file);
echo "CHMODed $file";
}
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.ftp-chmod.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40786
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40786&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40786&report=yes
Search -- http://master.php.net/manage/user-notes.php