Jump to content

Recommended Posts

Posted

Hi,

 

Here is my problem and I need you guys' help if you can. Appreciate it.

 

I have a script that I need to write to a file under /home/my_user_name/public_html/dir1/file1.

 

I use fopen($file_path, "a") and I would get the following error if I make that file permission as 755:

 

[function.fopen]: failed to create stream: Permission denied in ...

 

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?

 

Please help. Thank you very much.

Posted

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.

 

Good luck!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...