PDA

View Full Version : mkdir() Not Working


donnie
2003-09-12, 02:43 AM
I have Linux RedHat 7.3 server. Previously I have enabled the Safe mode On. But now
I have switch the safe_mode off and check it by running the following PHP code:
<?
if (get_cfg_var("safe_mode") == 1)
{
echo "safe mode is on";
}
else
{
echo "safe mode is off";
}
?>

It's returning 'safe mode is off'. But when I run the mkdir() command to make the directory from php it will give me an Error: 'Permission denied'. The code which I executed is:


<? $madedir = mkdir("abc" , 0777) == TRUE ? 1 : 0;
if($madedir == 0)
{
echo "Dir Not Created";
}
else
{
echo "Dir Created";
}
?>


It's also giving an Error: 'Permission denied'.

I have check it but it's not running any Safe Mode Disabled Commands. Please tell me, if you have an idea what's the problem.

Tino Didriksen
2003-09-12, 07:05 AM
The parent dir must also be chmod'ed to allow new dirs to be created.

dhigbee
2003-09-12, 09:30 AM
Donnie is right. Sounds to me like you are either trying to create the sub-directory in a directory owned by root or another user. Or, you are not running the script as the user who owns the directory. In either case, you need to verify owners of the script and directory.

If you are creating these directories in another users environment, you will have to be root user to do so.

By the way, you really should not create a directory with 777 unless you absolutely need it to be fully open by all users. 755 is much safer.

Don

donnie
2003-09-12, 11:24 AM
Thanks a lot. I already got my mistake.