homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

mkdir - Permission Denied :o(

 1:43 pm on Jan 24, 2005 (gmt 0)

Hi again,

I'm having a spot of bother with the mkdir command, I get a permission denied error. I've tried running the command in the Linux shell and works okay.

I just can't understand why it won't create a directory.

Any ideas?


// current directory
echo getcwd() . "<br><br>";


// current directory
echo getcwd() . "<br><br>";


#echo "NEW DIR: $new<br><br>";


This is the output...

mkdir(/home/oz/domain.com/Arts/Art_Noveau/): Permission denied

I've tried running this command, mkdir /home/oz/domain.com/Arts/Art_Noveau/ in linux shell, and it works fine.




 2:21 pm on Jan 24, 2005 (gmt 0)

The fact that you can do it while logged in might suggest you CHMOD the permissions in your directory ..?

the PHP manual for chmod.

There may also be a problem with your host using the $home_dir. In many cases this would take you back beyond the /web directory (which is how many hosts are set up) and of course they are not going to allow you to write to this directory.

It seems that you may just need a two liner...

$new = "../your_directory";
mkdir("$new", 0700);

The "../" signifies the "home" directory. This way you don't have to define it. So if you wanted to go further, youd just:

$new = "../$otherpath/$thispath";

There is no need for the . '/' . '/' in my opinion. I use double quotes.

Hope this helps :0)



 2:22 pm on Jan 24, 2005 (gmt 0)

Hi Woldie,

If 'you' can create a sub dir but your 'httpd-user' cannot, it may be a problem with the permission setting of the dir (Arts/) above that sub dir. Make sure, that both your shell user as well as your webserver can write and execute that Arts/ directory, fiddling with chown user:group on that above-dir and then doing a chmod on Arts/ accordingly.



 2:37 pm on Jan 24, 2005 (gmt 0)

Thanks guy for the input.

I've finally cracked it!

I needed to do a chmod 777 in a directory where I will be creating all directories on the fly, if that makes any sense.

The script as it stood wouldn't let me do the chmod command, I think it was what Romeo said, but anyway I've got it to work.

So essentially create a directory called 'directory' chmod 777 that, and then let the script create the directories as required in that directory.

eg. /home/oz/domain.com/directory/Arts

Thanks again.



 1:19 pm on Jan 25, 2005 (gmt 0)

Changing directory perms to '777' is ... wrong. What you should do is chmod the directory to '775' and chgrp to 'www-data' (or 'apache' or 'nobody' or whatever your webserver runs as).


 2:28 pm on Jan 25, 2005 (gmt 0)

Thanks dcrombie,

I see what you mean by chmod 777, because now I can't even remove the directories I've created.

Thanks for the tip.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved