I have an image, for example:
This file was created using a script through a cron. fileowner() returns ‘48’. File permissions is 0644.
I want to write over this image with a new image, with a php script that is run through a browser (user: apache). It doesn’t work.
I can unlink() the image file, which does work, but it still doesn’t let me write a new image to that path.
I can’t chown() or chmod() in my php script, because apache isn’t the owner of the file.
How can I get around this - or how can I make my cron create the image with user ‘apache’?
I do not have an answer to your question. But I do think it is a good question and I would like to know myself. So when you find an answer, could you post back and let us know what you did?
You need to give Apache rights to the folder the file is inside. When you have that you can change the rights on the file, and then delete/overwrite it.
The best way to do this is making certain that the Apache user and the CLI user is in the same group, and then give the group access to modify the folder.
That works - to an extent. It seems the drive I am trying to write to is full, which brings up another problem.
I posted my new problem here: