php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39485 mkdir() fails when pathname have space(s) on the final
Submitted: 2006-11-13 04:29 UTC Modified: 2013-02-18 00:33 UTC
Votes:6
Avg. Score:3.0 ± 1.2
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:4 (100.0%)
From: v1d4l0k4 at gmail dot com Assigned:
Status: No Feedback Package: *Directory/Filesystem functions
PHP Version: 5.2.0 OS: Windows XP (Win32 only)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
4 - 1 = ?
Subscribe to this entry?

 
 [2006-11-13 04:29 UTC] v1d4l0k4 at gmail dot com
Description:
------------
The 'mkdir' function doesn't function correctly on Windows when the pathname contain space(s) on the final. PHP returns a warning, and the directory isn't created:

Warning: mkdir() [function.mkdir]: Invalid argument in X on line Y

Temporary fix: use trim() on the pathname

Besides, if the pathname contain space(s) on the start, the directory is created when couldn't even so (in accordance with the behavior of Windows Explorer).

Reproduce code:
---------------
<?php

mkdir('pathname ');
mkdir(' pathname');

?>

Expected result:
----------------
<?php

mkdir('pathname '); // Succeeds, but trim() before, in accordance with the behavior of Windows Explorer
mkdir(' pathname'); // Succeeds, but trim() before, in accordance with the behavior of Windows Explorer

?>

Actual result:
--------------
<?php

mkdir('pathname '); // Fails
mkdir(' pathname'); // Succeeds even not being recommended

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-21 21:03 UTC] tony2001@php.net
Cannot reproduce:

C:\>php -r "var_dump(mkdir('dirname '));"
bool(true)

 [2006-11-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-07-14 03:50 UTC] felipe@php.net
-Status: No Feedback +Status: Feedback
 [2010-07-14 03:50 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2013-02-18 00:33 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 22:01:31 2024 UTC