开发者

php weird file_exists bug

Has anyone got any idea to why doesn't the following work ?

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

echo 'Yes its there.';

The problem is with the spaces. I have checked the file exists,dbl checked n triple checked im going nuts. :(

H开发者_如何学Pythonelp


file_exists works on the file system and not via HTTP. So %20 will not be recognized as space but literally as %20; use spaces instead:

$file = 'images/thumbs/1 - Copy.jpg';


$file = rawurldecode('images/thumbs/1%20-%20Copy.jpg');


try these two

$file = 'images/thumbs/1\ -\ Copy.jpg';
$file = 'images/thumbs/1 - Copy.jpg';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜