Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-06-2009, 08:45 PM   PM User | #1
moyyom
New to the CF scene

 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
moyyom is an unknown quantity at this point
Exclamation PHP permissions error.

Currently I have a function that writes a PHP file to a directory given a random string.

My write function is as follows:

PHP Code:
function write($where$what){
$myFile $where;
$fh fopen($myFile'w');
fwrite($fh$what);
fclose($fh);

The only problem with it is, the index.php file that I create in the directory needs to be able to run a password protect PHP script. I don't know how to write a file AND give it permissions. If anyone could help me do that, it would be awesome.

I need to give the file that the write() function creates permissions... <-- simple form.
moyyom is offline   Reply With Quote
Old 05-06-2009, 08:59 PM   PM User | #2
eak
Regular Coder

 
eak's Avatar
 
Join Date: Jun 2002
Location: Nashville, TN
Posts: 354
Thanks: 0
Thanked 26 Times in 26 Posts
eak is on a distinguished road
you need to chmod() your file.

http://us2.php.net/chmod
__________________
eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."
eak is offline   Reply With Quote
Old 05-07-2009, 02:44 AM   PM User | #3
nobackseat88
Regular Coder

 
Join Date: Dec 2007
Posts: 145
Thanks: 5
Thanked 5 Times in 5 Posts
nobackseat88 is an unknown quantity at this point
chmod it to 777
nobackseat88 is offline   Reply With Quote
Old 05-07-2009, 02:58 AM   PM User | #4
moyyom
New to the CF scene

 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
moyyom is an unknown quantity at this point
The problem is, it creates a file every time a user submits the form. I know about CHmod, but I don't want to have to CHMod Every Single Form a user submits. That's a lot of work. Is there a way to automate Chmod using PHP? A script with full permissions dropping permissions to a lower file?
moyyom is offline   Reply With Quote
Old 05-07-2009, 03:03 AM   PM User | #5
nobackseat88
Regular Coder

 
Join Date: Dec 2007
Posts: 145
Thanks: 5
Thanked 5 Times in 5 Posts
nobackseat88 is an unknown quantity at this point
If the file that is being created is in a variable, it's simple.

Code:
chmod("$myfile", 777);
nobackseat88 is offline   Reply With Quote
Old 05-07-2009, 03:49 AM   PM User | #6
moyyom
New to the CF scene

 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
moyyom is an unknown quantity at this point
thanks so much for that. This problem has been resolved. And in an efficient manner
Thanks all who helped.
moyyom is offline   Reply With Quote
Old 05-07-2009, 03:39 PM   PM User | #7
thecsslab
New to the CF scene

 
Join Date: May 2009
Location: Bulgaria
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
thecsslab is an unknown quantity at this point
I only suggest removing the double quotes in the provided PHP snippet since it speeds down the PHP parser.
thecsslab is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting 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

Forum Jump


All times are GMT +1. The time now is 01:56 AM.


Advertisement
Log in to turn off these ads.