file_exists returns false 即使文件存在于我的 yii php 应用程序中

file_exists returns false even when the file exists in my yii php application

我已经阅读了很多与我同名的问题,但其中 none 对我有所帮助..

上图是以下函数的输出..

foreach (  $products as $product) {

            $file = Library::getCatalogUploadPath().$product['image'];
            echo $file.'<br>';
            if( file_exists($file)){
                echo  $file;
            }
            else {
                echo "no".'<br>';
            }

          }

这里是函数 getCatalogUploadPath()...

public function getCatalogUploadPath()
    {
        return Yii::app()->params['config']['document_root'].Yii::app()->params['config']['upload_path'].'catalog/';
    }

这是'config'..

'config' => array(
            'site_url' => 
            'http://l/git/cart.git/',//example:http://www.cartnex.org/
            'document_root' => $_SERVER['DOCUMENT_ROOT'],
            'upload_path'=>'git/cart.git/uploads/',
            )

文件存在的证明:

文件名 $product['image'] 格式错误。它不包含文件扩展名,这就是为什么 file_exists() returns false