Search code examples
phpwampmkdir

mkdir('../media/magazines/'.$id, 0755) shows a warning: no such file or dir


I don't know whats wrong with this function. I am trying to create a directory $date/$recid inside the "media/magazines" directory. This function some times creates it but sometimes shows a warning

Warning: mkdir() [function.mkdir]: No such file or directory in C:\wamp\www\locallink\cpl_locallink\magazine.php on line 77
Call Stack

I am using it on windows 7 with wamp as my server.


Solution

  • Try this:

    mkdir('../media/magazines/'.$id, 0755, True)
    

    The main point here is the new argument: the third argument True, that said mkdir that it must create directories recursively. When recursion switched off all parent directories must be already existent (../media/ in our case); but when recursion switched on, they will be created automatically.