I have this simple line of code:
mkdir($path_to_rpi, 0755);
chgrp($path_to_rpi, 'sambashare');
Directory is created as www-data and group is the same. www-data owns the directory and yet the chgrp fails?!?
What am I missing here?
Confirming my comment:
You must be a member of the group to which you are changing ownership to.
http://unixhelp.ed.ac.uk/tasks/change_own.html
(dead link; use this one: https://theory.uwinnipeg.ca/UNIXhelp/tasks/change_own.html)