...

View Full Version : read all files



webandwe
07-25-2007, 02:29 PM
Hi,

I am trying to chmod all my images in one dir. but I cannot get it to work...
How do I code the first part so it reads all my files I have in the dir?

I want to change all my images cmod settings by running the script once.



$file = all my files in my images folder or this directory


$old = umask(0);
chmod("$file", 0644);
umask($old);

// Checking
if ($old != umask()) {
die('An error occured while changing back the umask');
}

mattis2k
07-25-2007, 04:49 PM
$objHandle = opendir($strDir);
while(($strFile = readdir($objHandle)))
{
if($strFile != ".." && $strFile != ".")
{
//chmod files here
chmod($strFile, 0644);
}
}
closedir($objHandle);

GO ILLINI
07-25-2007, 07:49 PM
you could just exec the regular *nix command

chmod -R #### *
that chmod's recursively with #### permissions and on all files in the current directory. Take off the -R to stop it from chmoding subdirectories.

-Adam



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum