Nov 22, 2009

Fopen Doesn't Work - though I gave all permissions

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Fopen Doesn't Work - though I gave all permissions

ruben
Hi puny humans,

QUOTE
Warning: fopen(energy.txt): failed to open stream: Permission denied in /home/ruben/public_html/insel/emu.php on line 24

I'm getting error messages like this everywhere on my sites where I try to change text files using PHP, even though I thought the right permissions were assigned and it worked earlier.
Do you have any idea what I did wrong? Maybe some setting in Cpanel that I screwed up or something? Or something in my .htaccess file? I sadly don't know the time of the screw-up, so I can't link it to my actions. I suspect something in .htaccess, that's why I post it here:
CODE
php_value upload_max_filesize 70M

php_flag register_globals off
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
AddType application/x-httpd-php rss
AddHandler application/x-httpd-php rss

I am using the fopen functions, not popen and the files are set to have their user rights set to "everyone may do anything" (i believe the number is 666?).

All help appreciated,
Ruben

 

 

 


Comment/Reply (w/o sign-up)

Houdini
You need to have them upload to a directory with chmod 777 (that directory is just for file uploads and must have full permissions)

Your .htaccess should have the below in it for 70Megabyte

CODE
post_max_size = "70M"
upload_max_filesize = "70M"


Try that out!

Comment/Reply (w/o sign-up)

ruben
Oh, I'm sorry, my .htaccess made this go in the wrong direction. The file upload actually works fine (never tried more than 10KB though).
It is completely other parts of my website, for example my shoutbox, which is an old script, using only text files, that are changed with PHP. For some weird reason it doesn't work anymore. I just thought the .htaccess file might be related to the problem.

Comment/Reply (w/o sign-up)

Quatrux
Well, the files you are using has a different owner, that means php can't handle them, but it is a bit strange that you cannot open the files, what chmod you're having on the file ? for reading it is enough to have 644, but if you uploaded the files with cpanel or ftp client or through php, but using ftp functions, the owner is different, that means you cannot even chmod those files using php. If you did this when login with your cpanel and change the permissions with it to 777 so it would be readable and writable by everybody, maybe even cpanel file manager can do it.

If that does not work, look what kind of permissions does the directory have where the data file is placed and where the script is being executed, for reading you need 755 and for writing into a file in the directory of which you're (php) not the owner needs 777 and check the directories before..

You haven't done anything with safe mode through .htaccess ? :?

Comment/Reply (w/o sign-up)

vujsa
Read these:
http://www.astahost.com/index.php?act=ST&f...indpost&p=66651
http://www.astahost.com/index.php?act=ST&f...indpost&p=56366

Anytime a PHP script creates a file, the server is the owner of the file. The user 0 as he has become known. This is why you have to set writting permissions on files that PHP writes to that you created.

Run the cleanup script from the links above to change the problem file or directory's permissions. Then you will have the access you need to write to the file.

This may be just one of your problems.
vujsa

Comment/Reply (w/o sign-up)

ruben
Hi. I swear last time I checked, the permissions were perfectly right, but now they were wrong.. Dunno, what I did, but now I fixed them and it works. Thanks for your tips anyway...

Ruben

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


See Also,

*SIMILAR VIDEOS*
Searching Video's for fopen, doesnt, work, gave, permissions
advertisement



Fopen Doesn't Work - though I gave all permissions

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com