Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > php fopen(), permission denied

php fopen(), permission denied
Thread Tools
Fresh-Faced Recruit
Join Date: May 2002
Location: Ft Lauderdale
Status: Offline
Reply With Quote
Jul 23, 2002, 11:25 PM
 
Anyone know what might cause a permission denied error on fopen()?
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">if (!($file = fopen(&quot;filename.html&quot;, &quot;w&quot)) die(&quot;Error.&quot;</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">The file does not exist, if I create it manually I still get the error.
     
Mac Enthusiast
Join Date: Jul 2002
Location: Leiden, Netherlands
Status: Offline
Reply With Quote
Jul 24, 2002, 03:27 AM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by Vasudevelopa:
<strong>Anyone know what might cause a permission denied error on fopen()?
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">if (!($file = fopen(&quot;filename.html&quot;, &quot;w&quot)) die(&quot;Error.&quot;</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">The file does not exist, if I create it manually I still get the error.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">What do you have when you do a ls -l filename in the terminal ?
     
Senior User
Join Date: May 2001
Location: Nottingham, UK
Status: Offline
Reply With Quote
Jul 24, 2002, 04:32 AM
 
does the process have write/execute permissions on the directory that the file is in?
     
Fresh-Faced Recruit
Join Date: May 2002
Location: Ft Lauderdale
Status: Offline
Reply With Quote
Jul 24, 2002, 11:42 AM
 
ls -l gives -rw-r--r-- and staff as owner. I chmod 777 and it wrote the file. The problem is +w should create the file if it doesn't exist, which is what I need. So I can't give write permissions to the file if it doesn't exist yet.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">does the process have write/execute permissions on the directory that the file is in? </font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">How would I give permissions to the process?
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jul 24, 2002, 06:57 PM
 
You don't give permissions to the process - you give it to the parent folder of the directory you want to write into.

Go into terminal, type:

sudo chmod 755 /path/to/your/directory

Enter your password and you've got updated permissions.

Note that I ran into some trouble with my ISP when I tried the same. It seems that the user I was FTPing the files with caused problems with permissions - I ended up using a chmod 777 to get it to work (which is a BAD thing!). To keep it more secure, though, I relocated that folder outside the document root so there was no public access to it.
Computer thez nohhh...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:38 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2