3

有没有人知道为什么以下工作不起作用?

$file = 'images/thumbs/1%20-%20Copy.jpg';
if(!file_exists($file)){
 die('NOT THERE');  
}

echo 'Yes its there.';

问题在于空格。我已经检查了文件是否存在,dbl 检查了 n 三次检查我要疯了。:(

帮助

4

3 回答 3

7

file_exists在文件系统上工作,而不是通过 HTTP。所以%20不会被识别为空间,而是字面意思为%20; 改用空格:

$file = 'images/thumbs/1 - Copy.jpg';
于 2010-11-30T15:45:40.977 回答
1

试试这两个

$file = 'images/thumbs/1\ -\ Copy.jpg';
$file = 'images/thumbs/1 - Copy.jpg';
于 2010-11-30T16:16:36.637 回答
1
$file = rawurldecode('images/thumbs/1%20-%20Copy.jpg');
于 2010-11-30T16:06:08.220 回答