Change the directory owner and group:
sudo chown www-data:www-data /var/www/[folder]
Allow the group to write to the directory with appropriate permissions:
sudo chmod -R 775 /var/www
Add yourself to the www-data group:
sudo usermod -a -G www-data [user]