[function.fopen]: Failed To Create Stream:

liunx

Guest
Hi,<br /><br />Here is my problem and I need you guys' help if you can. Appreciate it.<br /><br />I have a script that I need to write to a file under /home/my_user_name/public_html/dir1/file1.<br /><br />I use <!--coloro:blue--><span style="color:blue"><!--/coloro--><b>fopen($file_path, "a") </b><!--colorc--></span><!--/colorc-->and I would get the following error if I make that file permission as 755:<br /><br /><b> [function.fopen]: failed to create stream: Permission denied in ... </b><br /><br />So I think it's because Apache doesn't have the permission to write under that directory. I am wondering is there any way (such as using .htaccess) to make fopen work and I still can set the file permission as 755?<br /><br />Please help. Thank you very much.<!--content-->
No way you can do this with permission set to 755. The last number there ("5"), represents the "world" permission. A permission of "5" means they can read and execute the file, but not write. For PHP to programmatically write to the file, you will normally need to set the permissions to 666 (or 766, although if it's just a text file there's no particular reason you'd need that first "7" since you'd never try to execute it as a program.<br /><br />Good luck!<!--content-->
 
Top