Page 1 of 1
Creating directories and files
Posted: Mon Jul 28, 2003 12:13 am
by MT
I`m trying to create a file:
Code: Select all
<?php
$fp=fopen("somefile.php4","w");
?>
or a directory:
Server (Apache, Linux) responds:
"
Warning: fopen(somefile.php4): failed to open stream: Permission denied ..."
or
"
Warning: mkdir(somedir): Permission denied ..."
respectively.
Please explain what`s wrong.
On my home computer (Windows 98, Microsoft Personal Web Server) it works fine.
...
Posted: Mon Jul 28, 2003 2:00 am
by kettle_drum
The permissions for writting to the folders that your attempting to do will be not aloud. CHMOD the dir so that you can write to it.
Re: Creating dirs & stuff
Posted: Mon Jul 28, 2003 5:38 am
by Black Unicorn
If PHP is running as an Apache module, I found that you have to change the directory ownership as well.
In my case it didn't work until I chown'ed the directory to httpd. But once I did that, I couldn't ftp using anything but httpd as a username ...
I hope this advice doesn't cause more problems than solutions.
Regards,
H
Creatinf directories and files
Posted: Tue Jul 29, 2003 12:56 pm
by MT
Thanks for replies.
I`ve understood what the problem was: your FTP-client and your PHP-scripts have different UIDs, i.e. they are two different owners. They can`t freely manipulate each other`s folders and files, unless they have permissions set to 0777. And even then, it seems, they can`t delete each other`s files and folders.
So my solution was as follows.
I first made a directory with my FTP-client inside the directory where scripts reside and set its permissions to 0777.
Then altered the script to make it create files and directories in that directory.
Of course, I had to make respective changes all over my site, because of the additional directory.
Now it all works fine.
