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;


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.