system("chgrp www-data file.bar"); system("chmod 664 file.bar"); #For the directories that are created: system("chgrp -R www-data foodir"); system("chmod -R 664 foodir");