allow php files to write to locations other than those owned by www-data

I am able to write content from a php file opened in the browser to a certain location /var/www/data which I configured as follows

cd /var/www/
sudo mkdir data
sudo chown www-data:www-data data
sudo chmod 755 data

However, is it possible to write similar data to another location like /var/www/html/MyProjectRootFolder which is not owned by www-data ?


Generally the web server's configuration is not going to allow applications to write to folders outside of their own Doc root. However, you could do something like symlink /var/www/html/MyProjectRootFolder to a location like /var/www/data within your Doc root that the application already can write to.

Depending, you may also need to make sure that the web server user still has read permissions to the symlinked content, or that won't work either.