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? Quote 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); } } ?> Quote 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 Quote 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 ] Quote Link to comment https://forums.phpfreaks.com/topic/51031-chmod/#findComment-251174 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.