|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32349 basename with \
Submitted: 2005-03-17 09:28 UTC Modified: 2005-03-31 01:00 UTC
From: zamorov at edinorog dot ru Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: php4-STABLE-200503181130 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: zamorov at edinorog dot ru
New email:
PHP Version: OS:


 [2005-03-17 09:28 UTC] zamorov at edinorog dot ru
basename not work correctly with windows path

Reproduce code:
$win = basename('C:\Windows\win.ini');
$unix = basename('/usr/local/etc/win.ini');

Expected result:
$win = 'win.ini';
$unix = 'win.ini';

Actual result:
$win = 'C:\Windows\win.ini';
$unix = 'win.ini';


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-18 14:41 UTC] zamorov at edinorog dot ru
That problem remained open.
 [2005-03-18 15:08 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

"On Windows, both slash (/) and backslash (\) are used as 
directory separator character. In other environments, it is 
the forward slash (/)." 
 [2005-03-20 11:28 UTC] zamorov at edinorog dot ru
Sample. I'm upload file from windows to unix.

$_FILES[etc]['name'] contain path with backslash, but basename understand only forward slash.

$imageName =& array_pop(split('/', strtr($_FILES['image']['name'], array('\\' => '/'))));
rather than
$imageName =& basename($_FILES['image']['name']);
wise choice?
 [2005-03-20 11:42 UTC]
On unix "\name\containing\slashes" is a perfectly valid *directory or file* name, so why do we have to force users not to use such names? 

 [2005-03-31 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".
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 29 02:01:24 2020 UTC