Using the chown() and chgrp() Functions
<?php
$dr = @opendir("/tmp/");
if(!$dr) {
echo "Error, couldn't open /tmp/!";
exit;
}
while(($filename = readdir($dr)) !== false) {
chown($filename, "php");
chgrp($filename, "phpgroup");
}
closedir($dr);
?>
Related examples in the same category