PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Warning: chmod(): Operation not permitted in /xxx/xxx.php on line nn
Actually I want to write data to a file - if the file does not exist then create it. This file may be deleted manually many times. So I cannot chmod it to 777 manually.
I cant use chmod($ilename,0777) because the filename may not exist.
anjanesh wrote:I cant use chmod($ilename,0777) because the filename may not exist.
How about checking wheter file exists before that using file_exists();?
I guess PHP or Apache running user (www or nobody in most cases) doesn't have permission to write on parent of "folder" directory. You would have to chmod chown the parent directory.
if (!file_exists("/example/file.dat")) {
fopen('/example/file.dat', 'w');
}
I think anjanesh is pointing out PHP doesn't have permission to write to that directory.
So, as I said, anjanesh needs to make the parent directory writable to Apache user.