LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP won't copy file as read/write just read only (https://www.linuxquestions.org/questions/programming-9/php-wont-copy-file-as-read-write-just-read-only-4175727471/)

pizzipie 07-28-2023 08:52 PM

PHP won't copy file as read/write just read only
 
I have all my directories including [/var/www/html, set to user:group - rick:www-data.

"rick" is in www-data group and www-data is in rick group. Permissions are 0775. When I try to copy a file, with php script, to one of these directories the permissions on the copied file are read-only. Any solutions out there to create read/write files.

Thanks R

NevemTeve 07-28-2023 11:45 PM

Use chmod on the file.

pizzipie 07-29-2023 02:30 PM

Thanks for reply,

I would rather the script write the file directly rather than using bash after the fact.

R

NevemTeve 07-29-2023 02:50 PM

Well, bash has nothing to do with this.

ntubski 07-29-2023 04:23 PM

You can try umask also: https://www.php.net/manual/en/function.umask.php

Although it says
Quote:

Avoid using this function in multithreaded webservers. It is better to change the file permissions with chmod() after creating the file. Using umask() can lead to unexpected behavior of concurrently running scripts and the webserver itself because they all use the same umask.

scasey 07-29-2023 05:42 PM

Quote:

Originally Posted by pizzipie (Post 6444928)
I have all my directories including [/var/www/html, set to user:group - rick:www-data.

"rick" is in www-data group and www-data is in rick group. Permissions are 0775. When I try to copy a file, with php script, to one of these directories the permissions on the copied file are read-only. Any solutions out there to create read/write files.

Thanks R

Writeable by who? Please post the owner and permissions of the copy.
Quote:

Originally Posted by pizzipie (Post 6445060)
Thanks for reply,

I would rather the script write the file directly rather than using bash after the fact.

R

PHP can chmod a file it created.


All times are GMT -5. The time now is 07:32 AM.