Unstoppable Domains โ€” AI Assistant

Check to see if file exists

Spaceship Spaceship
Watch
Impact
19
hey
i am using a script that gets an image from the directory and displays it using
PHP:
<img src='[imgdir]".$media['nameid'].".png' width='[twidth]' height='[theight]' style='border: 1px solid #000000;' />
but i want it to check to see that "[imgdir]".$media['nameid'].".png' " exists..and if it does..then i want it to do this..otherwise i want it to show another image...i know i am suppose to use the IF statement but i cant figure out what command to use to see if the file exists?
thanks
P.S: rep will be added ;)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
You should be able to use something like:
Code:
$img_filename = '[imgdir]' . $media['nameid'] . '.png';
if ( file_exists( $img_filename ) {
     echo "<img src='" . $img_filename . "' width='[twidth]' height='[theight]' style='border: 1px solid #000000;' />"; 
}
 
0
•••
Appraise.net
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back