ID:               48547
 User updated by:  BinaryKitten at jkrswebsolutions dot co dot uk
 Reported By:      BinaryKitten at jkrswebsolutions dot co dot uk
 Status:           Bogus
 Bug Type:         SPL related
 Operating System: win32 only - WinXP SP3
 PHP Version:      5.2.9
 Assigned To:      garretts
 New Comment:

FilesystemIterator is not available in the 5.2.9 codebase, 5.3+ so
FilesystemIterator doesn't resolve the issue. What does is passing the
$_SERVER['DOCUMENT_ROOT'] to realpath before passing the result to the
DirectoryIterator;

<?php
$dir = new DirectoryIterator( realpath($_SERVER['DOCUMENT_ROOT']) );
echo "<strong>".$dir->getPath()."</strong><br />";
foreach($dir as $file ) {
  $dirName = $file->getPathname();
  echo $dirName."<br />";
}
?>

This "solves" the issue.


Previous Comments:
------------------------------------------------------------------------

[2009-08-19 18:02:22] [email protected]

Use the FilesystemIterator class (a subclass of DirectorIterator) if
you want to force the directory separator to the forward slash.

Directory iterator only supports the default platform slash.

http://us.php.net/manual/en/class.filesystemiterator.php

// will use forward slashes.
$dir = new FilesystemIterator( $path, 8192 );





------------------------------------------------------------------------

[2009-06-14 19:22:59] webmaster at asylum-et dot cm

I have tested this on Windows XP SP3 with PHP 5.2.5 and have the same 
findings as BinaryKitten at jkrswebsolutions dot co dot uk

------------------------------------------------------------------------

[2009-06-14 11:47:49] BinaryKitten at jkrswebsolutions dot co dot uk

Description:
------------
When using the DirectoryIterator to go through files/folders on Windows
under apache, the path has a mismatch of \ and /

Reproduce code:
---------------
<?php
$dir = new DirectoryIterator( $_SERVER['DOCUMENT_ROOT'] );
echo "<strong>".$dir->getPath()."</strong><br />";
foreach($dir as $file ) {
  $dirName = $file->getPathname();
  echo $dirName."<br />";
}
?>

Expected result:
----------------
With the Document root as C:\HTDOCS Apache returns
$_SERVER['DOCUMENT_ROOT'] as c:/HTDOCS

Expected Output
C:/HTDOCS/.
C:/HTDOCS/..
C:/HTDOCS/css
C:/HTDOCS/index.php
C:/HTDOCS/js
C:/HTDOCS/

Actual result:
--------------
C:/HTDOCS\.
C:/HTDOCS\..
C:/HTDOCS\css
C:/HTDOCS\index.php
C:/HTDOCS\js



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48547&edit=1

Reply via email to