Join us on Facebook

Please wait..10 Seconds Cancel

1.03.2014

// // Leave a Comment

Simple Script To Display Image If no Images Exists using PHP


This is a simple script to display image,if no images exists it will display a default image.

index.php
<?
echo "
<center>
DailyPic
<BR><BR>

This is a Simple script to display a daily image, if no image exists it will display a default image.
</center>
<BR> ";
 include('potd.php');
?>
potd.php
<?
$date = date("Y-m-d");

// URL to Fullsize Images.
$image_url = "http://www.hungrydevelop.blogspot.com/demo/DailyPic/photos/";

// Path to Fullsize Images
$image_dir = "/home/www/codemunkyx/www/www.hungrydevelop.blogspot.com/htdocs/demo/DailyPic/photos/";

// URL to Thumbnail Images.
$thumb_url = "http://www.hungrydevelop.blogspot.com/demo/DailyPic/photos/thumbs/";

// Path to Thumbnail Images.
$thumb_dir = "/home/www/codemunkyx/www/www.hungrydevelop.blogspot.com/htdocs/demo/DailyPic/photos/thumbs/";

// Default Thumbnail if no image is available for Today
$default = "http://www.hungrydevelop.blogspot.com/demo/DailyPic/photos/default.jpg";

// Image Extension for Your Pics
$ext = ".jpg";
$photo = "$image_dir/$date" . $ext . "";
 if (file_exists ( $photo)){ 
       echo "
   <div align=center>
   <A HREF='$image_url/$date" . $ext . "' target='_blank'><IMG SRC='$thumb_url/$date" . $ext . "' border=0></A><BR>
   <A HREF='http://www.hungrydevelop.blospot.com' target='_blank'><font size=2>powered by: hungrydevelop.blogspot.com</FONT></A><BR>
   </DIV> 
  "; 
 } else { 
       echo "
   <div align=center>
   <IMG SRC='$default' border=0><BR>
   <A HREF='http://www.hungrydevelop.blogspot.com' target='_blank'><font size=2>powered by: hungrydevelop.blogspot.com</FONT></A><BR>
   </DIV>
  "; 
 } 
?>


0 comments:

Post a Comment