Here is my PHP code:
[root@file htdocs]# vi test.php
<?php
var_dump(file_exists('/usr/local/apache2/resumes/28/"Chapel Hill"/franky_li/"CV.doc"'));
?>
"test.php" [New] 5L, 100C written
[root@file htdocs]# php test.php
bool(false)
which says the file doesn't exists,but in fact it does:
[root@file htdocs]# ls -l /usr/local/apache2/resumes/28/"Chapel Hill"/franky_li/"CV.doc"
-rw-r--r-- 1 daemon root 36864 Oct 17 2008 /usr/local/apache2/resumes/28/Chapel Hill/franky_li/CV.doc
[root@file htdocs]#
seems it's indeed quote issue:
<?php
var_dump(file_exists('/usr/local/apache2/resumes/28/Chapel Hill/franky_li/CV.doc'));
?>
~
~
"test.php" 5L, 96C written
[root@file htdocs]# php test.php
bool(true)
[root@file htdocs]#
fixed now by using the following converter:
preg_replace('/\/([^\/\s]+\s+[^\/]+)(?:\/|$)/','/"${1}"/',$file);
to make it work in bash!