php fopen fails to open a file for writing in Mac OS X php fopen fails to open a file for writing in Mac OS X apache apache

php fopen fails to open a file for writing in Mac OS X


I was having this exact same problem. I had to make sure the permissions were correct for all of the parent folders as well. For instance, if (in OSX) trying to write to the directory ~/foo/bar/baz, I solved it with the command chmod -R 777 ~/foo.


I bet the issue is that your webserver or PHP instance is not running under the same user (arman), you can check this using the get_current_user() function. You can either configure apache to run with your privileges (ask in ServerFault) or give the folder more generous permissions, like 0777.

Another thing, are you sure $outFile maps to an absolute path? Try doing:

var_dump(is_file($outfile));


you need to make apache (assuming apache is server you are using) the owner or put in group (and give group write access) or give write access to all or etc.. IOW apache is the one actually executing the script, not you.