I have set up an apache2 webserver on a Debian Jessie machine. I am uploading files to the server using a PHP script, following http://php.net/manual/en/function.move-uploaded-file.php .
I have set up /etc/php/apache/php.ini to enable file uploads, and I can upload a file fine.
I want the uploaded files to have the permissions set as 0664. Having read around on Stack Overflow, in /etc/apache2/envvars I have done
umask 002
which I believe should set the PHP interpreter umask to be derived from apache, i.e. 002.
The file upload directory ownership and permissions are set to www-data:www-data 770 (i.e. the apache user).
However, when I move the temporary PHP file to the upload directory using move_uploaded_file, the file permissions are 600, i.e. group permissions are not preserved.
Can anyone provide any ideas as to what might be wrong?
Following comments below, I should have stated that I want the moved file to have 0664 permissions.
I also tried this:
chmod($_FILES['file']['tmp_name'], 0664);
rename($_FILES['file']['tmp_name'], $new_filename);
And this:
chmod($_FILES['file']['tmp_name'], 0664);
copy($_FILES['file']['tmp_name'], $new_filename);
But this didn't work, I still get 0600 in both cases for the moved file.