2016-05-26 14 views
0

Ich zeige Bild aus Datei mit PHP. Mein Code sieht wie folgt ausÜberprüfen Sie die Datei ist leer 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); 

Hier Wie kann ich überprüfen, ob das Bild in ProfileIcons/ leer ist?

Ich habe einen Zustand zu versetzen, so dass

if (image is present in `ProfileIcons/`) 

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

else (image is not present in the folder) 

    $image = Show default image 

Wie dies zu erreichen?

Antwort

2

Versuch in file_exists suchen

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{//}