Search code examples
phpmkdir

PHP Mkdir not executing recursively?


The following works in windows:

mkdir('../my/folder/somewhere/on/the/server', 0777, true);

I am talking about PHP mkdir.

It works perfectly, and creates the subfolders recursively. However, if I run the same command on a linux server, the folders aren't created.

Previously I solved this by breaking up the path and creating each folder one by one. But I don't want to do that because it should work with the "resurive" flag set to true. Why isn't it working?


Solution

  • Sorry, but there must be some problem apart from the mkdir command itself.

    This tiny example works as expected and recursively creates the directories for me when executed on Linux:

    #!/usr/bin/php
    <?php
    mkdir ('testdir/testdir2/testdir3',0777,TRUE);
    ?>