|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29797 mkdir function doesn't work correctly when path contains forward slashes
Submitted: 2004-08-23 14:41 UTC Modified: 2005-02-14 10:51 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: arnoud at procurios dot nl Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.0.0 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: arnoud at procurios dot nl
New email:
PHP Version: OS:


 [2004-08-23 14:41 UTC] arnoud at procurios dot nl
The 'mkdir' function doesn't function correctly on Windows when the path contains forward slashes. The part of the path with the forward slashes doesn't get created.

Reproduce code:

mkdir('c:\a\b\c\d', 0775, true);
mkdir('c:\e\f\g/h', 0775, true);


Expected result:
Two directories should have been created:
c:\a\b\c\d, and

Actual result:
Actual directories being created:
c:\a\b\c\d, and


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-01 16:56 UTC] alex dot pagnoni at solarix dot it
Actual workaround is to check for underlying os (look inside $_ENV['OS']) and, if it is Windows, convert all forward slashes using str_replace().
 [2004-09-29 09:07 UTC] php at nowhere dot net
The proper work around is to use the php defined constant PHP_DIR_SEPARATOR which is set according to the platform.
 [2005-01-06 03:14 UTC]
Note: The actual constant is DIRECTORY_SEPARATOR.

However, in PHP, in most (all?) cases \ and / are interchangable when dealing with the filesystem.

Why shouldn't this be the case for mkdir?
 [2005-02-14 10:51 UTC]
As far as I can see, PHP has nothing to do with it, as PHP just calls mkdir(supplied path).
And PHP doesn't use DIRECTORY_SEPARATOR with mkdir(), but your system's mkdir() is failing to create directory "g/h".
On the other side "g\h" is valid name for directory on Linux and mkdir("g\h") successfully creates it.

Marking this report as bogus.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 21 17:01:30 2024 UTC