Are you the owner or the webserver?
Everything you execute with the webserver should run as www
, _www
or www-data
(depending on the configuration; default values for different OS). So the webserver user is not in your group which causes that the file is not writeable by the webserver.
(P.s.: get_current_user()
is the script owner (e.g. what you set by chown), not the script running user. Current script running user data: var_dump(posix_getpwuid(posix_getuid()));
)