Results 1 to 10 of 12
I have a PHP script on my FC2 server running Apache that is having a problem writing, if I set the directory it is to write to to 777 it ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-23-2006 #1Linux Newbie
- Join Date
- Nov 2004
- Location
- Glacier, WA
- Posts
- 103
Permissions Error
I have a PHP script on my FC2 server running Apache that is having a problem writing, if I set the directory it is to write to to 777 it does fine, if i set it to 755 (as the script writer says) it will not. This script works other than that problem
This is the script:
<html>
<body>
<?php
srand(time());
$data1 = "This is a new file entry!\n";
$data2 = "This is a new file entry!\n";
$data3 = "This is a new file entry!\n";
$data4 = "This is a new file entry!\n";
$data5 = "This is a new file entry!\n";
$fileext = ".txt";
$filedir = "test";
$random1 = (rand()%99);
$random2 = (rand()%99);
if (!$file_handle = fopen($filedir."/".$random1.$random2.Date(YmdGysT).$fileext,"w" )) { echo "Cannot open file"; }
if (!fwrite($file_handle, $data1)) { echo "Cannot write to file"; }
if (!fwrite($file_handle, $data2)) { echo "Cannot write to file"; }
if (!fwrite($file_handle, $data3)) { echo "Cannot write to file"; }
if (!fwrite($file_handle, $data4)) { echo "Cannot write to file"; }
if (!fwrite($file_handle, $data5)) { echo "Cannot write to file"; }
echo "You have successfully written the file";
fclose($file_handle);
?>
</body>
</html>
Any ideas??
Bill
- 03-23-2006 #2
Your description suggests that the owner of the 'test' directory is not the same as the user running the script... (not enough information to determine anything certain about the group)
- 03-23-2006 #3Linux Newbie
- Join Date
- Nov 2004
- Location
- Glacier, WA
- Posts
- 103
The owner of the test directory is weloy and it is apache that writes the script, I tried changing the permissions to 775 but am not sure what should belong to what group
Bill
- 03-23-2006 #4
The real question is, "who all" do you want to be able to write to that directory?
- 03-23-2006 #5Linux Newbie
- Join Date
- Nov 2004
- Location
- Glacier, WA
- Posts
- 103
To this directory apache and weloy
- 03-23-2006 #6Linux Newbie
- Join Date
- Nov 2004
- Location
- Glacier, WA
- Posts
- 103
Thanks, that helped, I just changed the group to apache and the permissions to 775 and that worked, is there a better way to let apache write to the directory?
- 03-23-2006 #7
You figured it out before I could get it in the thread:
~ Set owner of 'test' to 'weloy'.
~ Set group of 'test' to 'apache'.
~ Set permissions of 'test' to '775'.
Yes, that's it!
- 03-23-2006 #8Linux Newbie
- Join Date
- Nov 2004
- Location
- Glacier, WA
- Posts
- 103
Thanks again, may I ask another question, how are you at PHP, I have a test script that will send mail with out a problem but I can not figure out how to get it to add a text attachment or the info in the text file?
- 03-23-2006 #9
I am not into PHP (yet) - I am very much into programming - more importantly, there are plenty of people on the forums who are [currently
] much more qualified PHP programmers than I am - post your script (if there is no problem in letting the whole world see it), and I'm sure someone here can probably help you - if not, I would be happy to see if I can help you...
- 03-23-2006 #10Linux Newbie
- Join Date
- Nov 2004
- Location
- Glacier, WA
- Posts
- 103
Will do, and thanks again
Bill


Reply With Quote
