shanthi Posted May 14, 2010 Share Posted May 14, 2010 I am new to php, in my site i need to upload 3 images and after uploading the uploaded image must display i the same page and at the same time it must save into sql Link to comment https://forums.phpfreaks.com/topic/201717-how-to-display-the-uploaded-image/ Share on other sites More sharing options...
Deoctor Posted May 14, 2010 Share Posted May 14, 2010 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 https://forums.phpfreaks.com/topic/201717-how-to-display-the-uploaded-image/#findComment-1058150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.