create a file with fopen()

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
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

create a file with fopen()

Post by HormonX »

Damn .. am confused ... am trying to create a file and put it in a directory using fopen(). This is what am doing ...

Code: Select all

$fd = fopen('/home/domain/public_html/new/pages/' . $menu_url , 'w+');
where $menu_url is a filename entered by the user. What i get in return when i try to submit a for is this ...


Warning: fopen(/home/domain/public_html/new/pages/test.php): failed to open stream: Permission denied in /home/domain/public_html/new/htmle/secure/newpage.php on line 53


i have looked and tried everything and still nothing...

I have checked the permition on the server and the folder pages is chmod 755 .... am confused ... help

Greg
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

The folder has to be writeable to the webserver user (nobody, www-data depending on distro). Either you:

- chown the folder to the webserver user or
- chgrp the folder to the webserver group and chmod it 775 (which I believe is the best choice) or
- chmod it 777.

-- Scorphus
Post Reply