I used the file_exists
function and it even finds the file.
The problem is that when it does not find, the message that does not exist does not appear (it does not go into the else).
<?php
$email = $v->email;
$email = strstr($email, '@', true);
$url = base_url();
foreach (array('png', 'jpg', 'gif') as $ext) {
if (!file_exists("./uploads/{$email}." . $ext)) {
continue;
}
$email = "$email.$ext";
$filename = "./uploads/{$email}";
if (file_exists($filename)) {
echo "O arquivo $filename existe";
} else {
echo "O arquivo $filename não existe";
}
echo "<img alt='' class='left avatar-comentario' src=\"" . $url . "uploads/$email\" maxwidth=\"300\" ,maxheight=\"400\" />";
break;
}
?>