Jump to content
xisto Community
Sign in to follow this  
ruben1405241511

Fopen Doesn't Work though I gave all permissions

Recommended Posts

Hi puny humans,

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:
php_value upload_max_filesize 70Mphp_flag register_globals offphp_flag magic_quotes_gpc offphp_flag magic_quotes_runtime offAddType application/x-httpd-php rssAddHandler 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

Share this post


Link to post
Share on other sites

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

 

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

Try that out!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 ? :?

Share this post


Link to post
Share on other sites

Read these:
http://forums.xisto.com/topic/88311-topic/?findpost=
http://forums.xisto.com/topic/86994-topic/?findpost=

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.