-1

I'm trying to recursively create directories, but I get this PHP warning:

Code:

<?php mkdir('data/1/0', 0755, true);

Output:

PHP Warning: mkdir(): Not a directory in /home/myScript.php on line 1

This is running on Linux.

Mostafa Berg
  • 3,211
  • 22
  • 36
Codefor
  • 1,318
  • 2
  • 13
  • 22
  • 1
    Thanks for taking the effort to write an FAQ style question, but this particular issue is too localized; the error already suggests that some part of the path is not a directory. – Ja͢ck May 20 '13 at 08:24
  • possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – NullPoiиteя May 20 '13 at 08:25
  • But when I encountered the problem,I searched the stackoverflow.com,but nothing useful found.None of them came up with the problem I mentioned below.I do not think the issue is too localized.The error does not suggests PART of the path is not a directory,okay? – Codefor May 21 '13 at 02:50
  • This question helped me. – Machado Aug 20 '16 at 04:37

1 Answers1

7

from the manual book, we can see:

bool mkdir( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] )

http://www.php.net/manual/en/function.mkdir.php

When we try to mkdir data/1/0, actually we can mkdir 0/ under the directory data/1. But when data/1 happens to be a file instead a directory, php will issue a warning PHP Warning: mkdir(): Not a directory

So, when you come with this warning, you can check that the prefix of the pathname is a file, where a directory was expected.

Machado
  • 8,965
  • 6
  • 43
  • 46
Codefor
  • 1,318
  • 2
  • 13
  • 22