Page 1 sur 1

Un IF qui recherche un fichier dans un dossier

Posté : 12 févr. 2006, 09:56
par auclairp
Bonjour à tous, voici mon petit problème

Premièrement voici mon code
<td class="image">	<? if ($showimg=="oui"){ ?>
								<A HREF="#" onClick="window.open('thumb_b/b_<? echo $rows['code']; ?>.jpg','_blank',' width=410, height=500');return(false)">
								<?	echo('<img src="thumb/'.$rows['code'].'_t.jpg"  >');}?></a></td>	
J'aimerais faire un IF qui va charcher dans mon dossier "thumb" voir si <? echo $rows['code']; ?>.jpg existe, sioui, il l'affiche, sinon il affiche autre chose exemple une autre image.

Je sais comment pour rechercher dans la Bdd, mais pour dans un dossier ???

Merci de votre aide

Posté : 12 févr. 2006, 10:42
par Cyrano
Utilise la fonction file_exists() :
<?php
$image = (file_exists("thumb_b/b_".$rows['code'] .".jpg")) ? "thumb_b/b_".$rows['code'] .".jpg" : "thumb_b/b_defaut.jpg";
?>
<A HREF="#" onClick="window.open('thumb_b/b_<? echo $image; ?>','_blank',' width=410, height=500');return(false)">

Posté : 12 févr. 2006, 11:08
par auclairp
merci ca fonctionne

:)