Reputation: 2688
I'm using file_get_contents and file_put_contents to read from a file and to write on other file. Both files have their file permissions set to 777, my question is: Is there any way to change the file permissions to 644 after the file_put_contents ?
I was using chmod('/usr/local/pem/vhosts/155030/webspace/httpdocs/filename', 0644); and chmod('filename', 0644); but both show an error "Warning: chmod(): Operation not permitted...
Upvotes: 0
Views: 1693
Reputation: 3517
You can only chmod files your user owns. Assuming you're running Apache with PHP as a module, your user is whatever Apache is running as. You will need to perform a chown (from the shell) as root (or optionally as the current owner of the files) in order to switch them to the user of your web server.
Upvotes: 3