It was a problem with the way I mounted the folder (which is a shared folder from VirtualBox host):
Should have been:
sudo mount -t vboxsf test /var/www/test
This allows my webserver to write to it, but there's still an issue. No matter who I mounted it under, I was unable to change chown/chmod afterwards. Is there any way to mount it so it allows changing ownership and permissions on subfolders and files?
#38 is www-data
sudo mount -t vboxsf -o rw,uid=38,gid=38 test /var/www/test