Jump to content

how to display the uploaded image


shanthi

Recommended Posts

hai

try with this code

 

<?
//usage =<img src="/img.php?fl=filename&type=1" alt="Image">
$ext = $_REQUEST["type"];
$filename = $_REQUEST["fl"];

/* $img is the directory where all your images are stored */

$img = "images/";

/* Firstly let's see if the variables have information in them */

if (!$ext) {

echo "Could not find appropiate information ext";

exit;

}

if (!$filename) {

echo "Could not find appropiate information Filename";

exit;

}

if (!$img) {

  echo "Could not find appropiate information IMG";

exit;

}

/* Extensions should be shown as numbers in the url for good protection. We will now redefine $ext matching the appropiate number from requested variable "type" */

if ($ext == 1) {

$ext = "jpg";

} else if ($ext == 2) {

$ext = "gif";

} else if ($ext == 3) {

$ext = "png";

}

/* The filename is not shown as numbers so we now have the "ingredients" needed to show the image. Now lets see if the image exists */

if (!file_exists($img . $filename . "." . $ext)) {

echo "Could not find image";

exit;

}

/* Now lets show the image. This is just a simple include statement */

include $img . $filename . "." . $ext;


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.