chmod($file, 0777);

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

chmod($file, 0777);

Post by phice »

So, I've come to a few breaking points in my program, and I need a solution to CHMODing a file.

File name: test_file.php
File location: /home/nncommunity/www/phpFF/test_file.php

First, I've tried to do the normal

Code: Select all

<?php
chmod("/home/nncommunity/www/phpFF/test_file.php", 0777);
?>
And, of course, it produces an error stating "Warning: Permission denied...".

I search the Phuse search engine for chmod() help in the forums, and find that some people have been able to successfully chmod a file using exec(). I've tried that, and nope. Not working.

I really don't want to put in FTP support, that's the very last resort, and if I have to, I probably won't go there.

I'm trying to edit a file through a browser, and when I do fwrite("test_file.php", "w+"); is gives me the same "Permission denied".

Any help? Thoughts?
Image Image
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

do u have the user privileges for that file?? aka are u the owner of the file
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

What do you mean owner? I have full access from '/home/nncommunity/' and on, if that's enough ownership.
Image Image
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

I've fixed my solution. :D Simply delete the file, then write the file (which will recreate the file).

The hardest of my problems always ends up being the simplest solution. You can quote me on that. ;)
Image Image
Post Reply