2016-05-26 1 views
0

J'affiche l'image du fichier en utilisant PHP. Mon code ressemble à ceciVérifiez le fichier est vide imagecreatefromgif - php

$image = @imagecreatefromgif(../ProfileIcons/".$use); 

$text_color = imagecolorallocate($image, $r, $g, $b); 
imagestring($image,$font_size,14,4, $code, $text_color); 

header('Content-Type: image/gif'); 
$kk = imagegif($image); 

imagedestroy($image); 

Voici comment puis-je vérifier si l'image présente dans ProfileIcons/ est vide?

Je dois mettre une condition telle que

if (image is present in `ProfileIcons/`) 

    $image = @imagecreatefromgif(../ProfileIcons/".$use); 

else (image is not present in the folder) 

    $image = Show default image 

Comment y parvenir?

Répondre

2

essayer de regarder dans file_exists

if (file_exists($filePath)) { 
// process image 
} else { 
// use default image 
} 
0
// check if file exist 
    if(file_exists('../ProfileIcons/'.$use.'')) 
    {// do what you like }else{//}