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 Quote Link to comment 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; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.