Apache PHP mkdir not writable?

If you ever find that you are creating a folder with PHP, and its immediately not writeable by Apache, then you’ve probably done what I did with the chmod. It needs to be an octal value, and PHP will not assume it is. So you have to prefix with a zero.

mkdir("/path/to/folder/structure/", 777, true);

Should actually be:

mkdir("/path/to/folder/structure/", 0777, true);

Took me a while to work it out, I thought it was something to do with Mac permissions…

One comment on “Apache PHP mkdir not writable?

  1. Ryan November 7, 2014 4:21 am

    Thanks! I was wondering WTF was wrong 🙂

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>