检查cakephp上是否存在图像

检查cakephp上是否存在图像,cakephp,Cakephp,我有一个CakePHP项目,我想知道如何检查扩展名为“.jpg”的图像是否存在。如果不使用扩展名为“.jpg”,将非常感谢您的帮助。bool file\u存在(字符串$filename) 检查文件或目录是否存在。如果文件名指定的文件或目录存在,则返回TRUE;否则就错了 我的图像路径,如app/webroot/img/upload/file123.jpg WWW\u ROOT定义您的webroot文件夹路径,DS定义“/” $image='file123.jpg'; $file = WWW_RO

我有一个CakePHP项目,我想知道如何检查扩展名为“.jpg”的图像是否存在。如果不使用扩展名为“.jpg”,将非常感谢您的帮助。

bool file\u存在(字符串$filename)

检查文件或目录是否存在。如果文件名指定的文件或目录存在,则返回TRUE;否则就错了


我的图像路径,如app/webroot/img/upload/file123.jpg

WWW\u ROOT定义您的webroot文件夹路径,DS定义“/”

$image='file123.jpg';
$file = WWW_ROOT . 'img' . DS . 'uploads' . DS . $image;
文件检查的条件

if(file_exists($file) && $image){
 enter your code if file exists
 }else{
 file not exists
}

你能解释一下吗。
if(file_exists($file) && $image){
 enter your code if file exists
 }else{
 file not exists
}