|
#1
|
|||
|
|||
|
Hi folks,
I'm running a php script that should create a new text file every time someone submits a form. The php feedback on the page works fine, but at the bottom of the page (where the fopen() function is) I get this message. Warning: fopen(results/lksd.txt): failed to open stream: Permission denied in /home/daacraig/public_html/indiana/classes/r641/www/quiz2/quizaction.php4 on line 150 Cannot open the file The code generating this error is $handle=fopen("results/$studentemail.txt", "a"); Any help would be appreciated. I'm a relative php beginner, but more importantly this is the first time I've tried running scripts on this host. Thanks, Dan |
|
#2
|
|||
|
|||
|
This looks like it may be a filesystem permissions problem. Using the file manager that can be launched from the cpanel, check the permissions of both the directory 'results' and of the file 'lksd.txt'. It is most likely the lack of write permissions in the results directory.
Try (but check the FAQ and admin before making a habit of) setting write permissions on the directory and file in question for all (owner, group and everyone). If security is set up properly, you should only need to do group, so try scaling back on giving world permission if the above works. --baqua |
|
#3
|
|||
|
|||
|
Thanks for the advice baqua. Unfortunately, I've even tried setting all permissions at 777 and still no luck. I also attempted to load a static text file and write to it, but still the same error message.
Dan |
|
#4
|
|||
|
|||
|
I'm having a similar problem. Anyone seen a resolution to this? My script which does "fopen" calls as well as "unlink" calls is getting all kinds of Permission denied errors. Even when dirs are set to 777. Script works fine on my local IIS...
|
|
#5
|
|||
|
|||
|
Well, I solved this: When I set my folder permission to 777. I assumed that chmod would propogate down to all sub directories. For some reason it did not. When I applied 777 to the exact folder containing the file I was trying to open/write, everything worked...
Why is chmod not recursive? |
|
#6
|
|||
|
|||
|
i think it is 2 different thing, chmod just folder and chmod folder with all containing files in it. this must be refer to the script manual which one you should chmod, just folder or folder with all in it. by default, it only chmod the folder. that's why it is not propogated automatically.
__________________
Ramones - It's Alive! |
|
#7
|
||||
|
||||
|
I had similiar problems where I had a form that allowed endusers to browse their PC and upload image files to a MySQL DB. Meaning no insult here, in addition to chmod 777 for the directory, I had set the following variables (I change the dir and filename to suit your example);
$path = "/home/username/public_html/results/"; $filename="lksd.txt"; username would be the accounts cpanel name. Then maybe fopen($path$filename) will hopefully work for you? Just a guess on my part. --ron
__________________
97 Trans Am |
|
#8
|
|||
|
|||
|
I'm getting 'Permission Denied' at my fopen line, while trying to creating a new file for writing, in a directory which has 777 permissions.
I wrote a script to run some tests, and check a few things (e.g. is php safe mode on?) See here: http://www.archivaty.net/forums/about54278.html#300599 ...others might find that useful, but at the end of the day it didn't help me. I still no idea why it's giving 'Permission denied'! You folks know any config setting I'm missing? |
|
#9
|
||||
|
||||
|
Quote:
|
|
#10
|
|||
|
|||
|
thank's
i've change the permission of my folder and the code run and the new file creats |
![]() |
| Bookmarks |
| Thread Tools | |
|
|