HostNed.comHostNed Forums
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 19, 2008, 05:50:24 AM
256 Posts in 93 Topics by 71 Members
Latest Member: sclemens
Home Help Search Login Register
HostNed Forums  |  WEB HOSTING  |  General Hosting  |  Topic: Using fopen in PHP 0 Members and 0 Guests are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Using fopen in PHP  (Read 1037 times)
Pixel.Gnome
Newbie
*
Posts: 2


View Profile
Using fopen in PHP
« on: July 22, 2007, 01:08:39 PM »

I have a PHP script, which gathers aload of content from various files, and then adds it all together, and writes a file to contain it.

When uploading to my server it does not work.... the fopen command give me a 'failed to open stream: Permission denied' message. the resutant file also cannot be written.

I am finding this most peculiar, because on the same server (different client site) I have a different script which has no problem with fopen.

does it make a difference that I uploaded the files (the entire site) from dreamweaver?
Logged
Dynaweb
Yep
Administrator
Full Member
*****
Gender: Male
Posts: 111


HostNed Admin


View Profile WWW
Re: Using fopen in PHP
« Reply #1 on: July 22, 2007, 10:17:39 PM »

Please state whether you are using Windows or Linux server and what the permissions are on the file.
Logged
Pixel.Gnome
Newbie
*
Posts: 2


View Profile
Re: Using fopen in PHP
« Reply #2 on: July 23, 2007, 03:22:50 AM »

Hi. sorry - should have sad.... it's a linux server, and I set no specific permssions on the files, but upon going into the cpanel file manager, I see the directories at 755, and the files are 644. these are default settings yes?.

I am no expert at these things, but I am very wary of changing permissions (I've seen you hall of shame). I am wondering though id the 'owner' of the files / directories is different depending on weather I use the file manager to create the directories of dreamweaver etc.

I mentioned that on another site I have a script which has no problem writing to a file, but I do recall now that initially there was an issue there which I solved by having the file initially created by the script itself, however, I can't seem to get this to work for me now....

Sorry if I am making some basic errors of concept here.

thanks for the help though
Logged
Dynaweb
Yep
Administrator
Full Member
*****
Gender: Male
Posts: 111


HostNed Admin


View Profile WWW
Re: Using fopen in PHP
« Reply #3 on: July 23, 2007, 11:04:42 AM »

You may need to set permissions on the file to 777.  I would not worry too much about security of that.  The Hall of Shame is mainly popular scripts that hackers find through google and know are exploitable.  Your setitng 777 to a specific file most likely would not offer any dangerous opportunities (database injections, cross-site scripting, etc...) for anyone.

As for the owners of the files, yes, I believe you are right.  I am not for sure, but I think that if the file is created by your FTP client, it is owned by your username.  If it is created by your FileManager, it may be owned by apache.  Thats why sometimes a CHMOD 644 (default) or 755 will do, but sometimes 777 is needed.

Hope this helps.
Logged
Pages: [1] Print 
HostNed Forums  |  WEB HOSTING  |  General Hosting  |  Topic: Using fopen in PHP « previous next »
Jump to: