Quick Image PHP Question?

  • Thread starter Thread starter Nosfer
  • Start date Start date
N

Nosfer

Guest
I need to make an image.php that would show an image. For example... if we have site.com/image.php?image=blablabla.jpg it should return blablabla.jpg in a the image.php file. I don't know how to do it and i'm sure it's not that hard but i found sooo many unrelated answers. Could someone help me with this code?
 
case ($UserInput['extension'] == ".jpg" || $UserInput['extension'] == ".jpeg" || $UserInput['extension'] == ".JPG" || $UserInput['extension'] == ".JPEG"):
$fh = fopen($UserInput['File_To_Open'], 'r');
if(!$fh)
{
echo "<div align=\"center\"><font color=\"red\">We are sorry, but the file could not be opened!<br><a href=\"javascript:self.close();\">Close window</a>";
fclose($fh);
exit;
}
else
{
$jpeg = imagecreatefromjpeg($UserInput['File_To_Open']);
if(!$jpeg)
{
echo "<div align=\"center\"><font color=\"red\">We are sorry, but the file could not be opened!<br><a href=\"javascript:self.close();\">Close window</a>";
exit;
}
else
{
header('Content-Type: image/jpeg');
imagejpeg($jpeg);
}
}
 
Back
Top