Jump to content

display image in a particular width and height


anujphp

Recommended Posts

Hello

i am displaying images from a paticular folder,the code is working fine but i want to display all the image in same width and height...the code for displaying images  is givn below

 

<?php 
// define absolute path to image folder
$image_folder = 'IMAGE FOLDER NAME'; 
// get the image name from the query string
  
   if (isset($_GET['pic']) && basename($_GET['pic']) == $_GET['pic'])
    { 
$pic = $image_folder.$_GET['pic']; 
if (file_exists($pic) && is_readable($pic))
 { 
   // get the filename extension
    $ext = substr($pic, -3); 
// set the MIME type
 switch ($ext)
  { 
   case 'jpg': $mime = 'image/jpeg';
   break; 
   case 'gif': $mime = 'image/gif';
    break; 
	case 'png': $mime = 'image/png'; 
	break; 
	default: $mime = false; 
 } 
 // if a valid MIME type exists, display the image
  // by sending appropriate headers and streaming the file 
  if ($mime)
   { 
    header('Content-type: '.$mime);
	header('Content-length: '.filesize($pic));
	 $file = @ fopen($pic, 'rb');
	  if ($file)
	   { 
	   fpassthru($file); exit; 
	   } 
	} 
} 
}

?>

 

I am calling the php pages as  below

FILENAME.php?pic=$imgname

 

THANK YOU IN ADVANCE....

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.