forumnz Posted May 12, 2007 Share Posted May 12, 2007 Is it possible to create a script that will allow me to change all images in a directory to 744? Link to comment https://forums.phpfreaks.com/topic/51031-chmod/ Share on other sites More sharing options...
neel_basu Posted May 12, 2007 Share Posted May 12, 2007 This code should work although not tested <?php $dir = "/etc/php5/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(getimegesize($dir . $file)) { chmod($dir.$file, 0744); } } closedir($dh); } } ?> Link to comment https://forums.phpfreaks.com/topic/51031-chmod/#findComment-251133 Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 Just spotted a typo in the above code: <?php if(getimegesize($dir . $file)) // Should be: if(getimagesize($dir . $file)) ?> Doesn't mean I've tested it, just noticed it Link to comment https://forums.phpfreaks.com/topic/51031-chmod/#findComment-251172 Share on other sites More sharing options...
neel_basu Posted May 12, 2007 Share Posted May 12, 2007 Ya you are right and also it should be if(getimagesize($dir ."/". $file)) { chmod($dir."/".$file, 0744); } [Note: If using windows use \\ instead of / else use DIRECTORY_SEPARATOR ] Link to comment https://forums.phpfreaks.com/topic/51031-chmod/#findComment-251174 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.