【发布时间】:2013-01-17 11:25:34
【问题描述】:
我正在尝试检查我的 symfony 2 的 /uploads 文件夹中是否存在文件。
$file = $this->getAssetUrl('/uploads/hd/'.$gift->getImage());
if(file_exists($file)) return $this->getAssetUrl('/uploads/hd/'.$gift->getImage());
else return $this->getAssetUrl('/uploads/large/'.$gift->getImage());
这总是返回错误,我调试了所有字符串并且路径正确,手动检查文件是否存在。有什么想法吗?
【问题讨论】:
-
var_dump($file)的输出是什么? -
@mamdouhalramadan string(30) "/uploads/hd/50f7d8c01f093.jpeg"
-
愚蠢的建议,但可能会有所作为。试试:
$this->getAssetUrl('uploads/hd/'.$gift->getImage());!! -
无效,我怀疑是路径问题,因为我检查了
-
我还使用 file_check 手动检查了完整的非相对路径,它再次给出了错误
标签: php symfony file-exists