带有空格的上传文件使得is_resource()失败 - php

I have a script checking if a file exists:

function fileExists($url) {
    $fh = fopen($url, 'r');
    if (is_resource($fh)) {
        fclose($fh);
        return true;
    }
    return false;
}

Everything went right until I tried to uploaded files whose name contains white space. Call $url the file's url, when I put it in the browser, it displays correctly the file, but is_resource($fh) always returns false. Someone could help ?

Before $fh = fopen($url, 'r'); add this:

$parts = pathinfo($url);
$url   = $parts['dirname'].'/'.rawurlencode($parts['basename']);

Btw, there is a PHP bug...