php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52466 PHP cannot see filenames with spaces
Submitted: 2010-07-28 10:27 UTC Modified: 2010-07-28 10:40 UTC
From: d dot reade at ReadesGroupServices dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5.3.3 OS: CentOS 5.5
Private report: No CVE-ID: None
 [2010-07-28 10:27 UTC] d dot reade at ReadesGroupServices dot com
Description:
------------
Using the scandir() method to fetch a list of filenames in a folder. Some filenames contain a space (via SSH this appears as "\ ", i.e. "test\ file.txt"). However PHP sees this file as "test_file.txt". This causes additional file operations such as file_exists() to return false.

Test script:
---------------
<?php
\\ path/to/folder/ contents:
\\ file.txt
\\ test\ file.txt

$scan = scandir('path/to/folder/');

foreach ($scan as $file)
{
    echo $file.'
';
}
?>

Expected result:
----------------
file.txt
test\ file.txt

Actual result:
--------------
file.txt
test_file.txt

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-28 10:33 UTC] degeberg@php.net
Works fine for me using latest SVN 5.3 build:

daniel@daniel-laptop:~/tmp$ ls -l
total 24
-rw-r--r-- 1 daniel daniel 0 2010-07-28 10:30 foo bar.txt
-rw-r--r-- 1 daniel daniel 0 2010-07-28 10:30 helloworld.txt
daniel@daniel-laptop:~/tmp$ php -r 'var_dump(scandir("."));'
array(4) {
  [0]=>
  string(1) "."
  [1]=>
  string(2) ".."
  [2]=>
  string(11) "foo bar.txt"
  [3]=>
  string(14) "helloworld.txt"
}
 [2010-07-28 10:40 UTC] d dot reade at ReadesGroupServices dot com
-Status: Open +Status: Closed
 [2010-07-28 10:40 UTC] d dot reade at ReadesGroupServices dot com
That's weird, it was doing it for me a second ago... and now it's not!! Sorry to waste your time, but thanks anyway.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 10:01:28 2024 UTC