[SOLVED] Is This Possible
Moderator: General Moderators
- luketheduck
- Forum Newbie
- Posts: 18
- Joined: Mon Apr 19, 2004 9:13 am
- Location: Aylesbury, Bucks, UK
Is This Possible
Something I want to implement on my site, but don't know if it's possible.
The page searches for an image to display based upon 2 variables which are set at page load.
What I want to do is search the directory for the image, but if it doesn't exist, to display a default image instead.
Is this going to be possible? Would be based around an if statement I guess, if image doesn't exist, show xxx instead.
The page searches for an image to display based upon 2 variables which are set at page load.
What I want to do is search the directory for the image, but if it doesn't exist, to display a default image instead.
Is this going to be possible? Would be based around an if statement I guess, if image doesn't exist, show xxx instead.
I'm using for this purpose
Code: Select all
<?php
//returns an image
//if no image-file is found, it returns default "blank.gif"
if (file_exists('graphix/'.$_GET["image"].'.gif')){
$image="http://www.mydomain.org/graphix/".$_GET["image"].".gif";
}
else{
$image="http://www.mydomain.org/graphix/blank.gif";
}
header("Location: $image");
?>- luketheduck
- Forum Newbie
- Posts: 18
- Joined: Mon Apr 19, 2004 9:13 am
- Location: Aylesbury, Bucks, UK
I use getimagesize, that way you can format the image.
Assume $img_var is your image filename.
Assume $img_var is your image filename.
Code: Select all
<?php
if (@$img = getimagesize($img_var))
{
print "<img src="$img_var" width="$img[0]" height="$img[1]">";
}
else
{
print "<img src="blank.gif">";
}
?>
Last edited by Grim... on Wed Jun 09, 2004 8:23 am, edited 1 time in total.
