Page 1 of 1
Problem with script - file permissions
Posted: Wed Aug 17, 2005 11:28 am
by pentiumhead
hi,
I have a script that needs to open and write to a file. It worked on my system but when i uploaded it to my hosting, the script will not run and i get the error:
Warning: fopen(output.php): failed to open stream: Permission denied in .......
how do i solve this problem
Kay
Posted: Wed Aug 17, 2005 11:29 am
by feyd
change the permissions so the script's user can write to the file.
chmod()
Posted: Wed Aug 17, 2005 11:40 am
by pentiumhead
This is what i got:
Warning: chmod(): Operation not permitted in /home/hyper/public_html/downloadp/chmod.php on line 9
Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
chmod("setup.php","0777");
?>
</body>
</html>
Posted: Wed Aug 17, 2005 11:42 am
by feyd
I'd guess your host disabled chmod(), as I guessed would happen.. you need to use your FTP client or your Host Manager to change the permissions then.
Posted: Wed Aug 17, 2005 11:43 am
by pentiumhead
I opened windows ftp and typed remote and i got the message:
214-The following SITE commands are recognized
ALIAS
CHMOD
IDLE
214 Pure-FTPd -
http://pureftpd.org/
how do i chmod?
Kay
Posted: Wed Aug 17, 2005 11:50 am
by feyd
Code: Select all
quote chmod <permission> <filename>
replace <permission> and <filename> with their respective things.
Posted: Wed Aug 17, 2005 12:02 pm
by pentiumhead
I got this:
Warning: Unknown(/home/hyper/public_html/downloadp/setup.php): failed to open stream: Permission denied in Unknown on line 0
Warning: Unknown(/home/hyper/public_html/downloadp/setup.php): failed to open stream: Permission denied in Unknown on line 0
Warning: (null)(): Failed opening '/home/hyper/public_html/downloadp/setup.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in Unknown on line 0
What do i do now?
Thanks for your help
Kay
Posted: Wed Aug 17, 2005 12:13 pm
by feyd
what permissions did you set?
Posted: Thu Aug 18, 2005 1:20 am
by pentiumhead
i set
quote chmod w setup.php
Posted: Thu Aug 18, 2005 3:45 am
by crazycaddy
I don't know much about chmoding manually but shouldnt it be
chmod 777 setup.php
Posted: Thu Aug 18, 2005 8:50 am
by pentiumhead
No luck
I connected to my server
and typed in the command line:
But still it didn't work.
kay
Posted: Thu Aug 18, 2005 8:55 am
by feyd
try
or other numbers (leaving the leading zero), such as 0746, 0766, but 0646 or 0746 shoudl do it.
Overall though, since you are writing to a php file, be very very very careful what you are writing in. If a user can control any aspect of the data being written, I'd be very very wary, because someone managing to inject a small amount of php code, can do wonderous amounts of damage.
Posted: Thu Aug 18, 2005 11:16 am
by zippee
Do you create the file/folder using php script? If yes then the owner of the file will be the server itself and you have no permission to change it. You can write another php script to change the file/folder permission and execute it on the server. Use chmod("setup.php","0777"); as provided in previous replies. Once you get there you can change the permission on your file manager or ftp (the file/folder is now open to all).
Posted: Fri Aug 19, 2005 1:17 am
by pentiumhead
I've tried chmod(). It didn't work.
I've tried through my hosting control panel, i've tried by connecting through ftp.
If I don't get a solution to this. I think there is nothing more to do than contact the hosting personnel. Everything on my coding part should be correct i guess.
Kay