note 60138 deleted from function.imagegif by nlopess

From: Date: Tue, 27 Dec 2005 20:55:13 +0000
Subject: note 60138 deleted from function.imagegif by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100814@lists.php.net to get a copy of this message
Note Submitter: gee at loveyouboo dot de ---- to create an picture with root path; if you have an problem to create image, e.g. if the image is in an forbidden order... createImage.php source: <?php $gifsupport = false; if(!function_exists("imagegif")) $gifsupport = true; // Create Image $bild = $_GET[bild]; if ($_SERVER["HTTP_HOST"] == "localhost") { echo $bild; } else { $htmldir = $_SERVER["DOCUMENT_ROOT"]; $htmldir = substr($htmldir,0,strrpos($htmldir,"/"))."/html/"; $pfad = "/home/www/webXXX/html/".$bild; // manuell $pfad = $htmldir.$bild; // automatic $imgType = strtoupper(substr($bild,strlen($bild)-3,3)); if ($imgType == "GIF") { if ($gifsupport) //GIF wird im Browser angezeigt //GIF Support GD 2.0.28 Header("Content-type: image/gif"); $im = imagecreatefromgif($pfad); Imagegif($im); ImageDestroy($im); } else { Header("Content-Type: image/gif"); $fn=fopen($pfad,"r"); fpassthru($fn); } } else if ($imgType == "PNG") { Header("Content-type: image/png"); $im = imagecreatefrompng($pfad); Imagepng($im); ImageDestroy($im); } else { //JPG wird im Browser angezeigt Header("Content-type: image/jpeg"); $im = ImageCreateFromJPEG($pfad); Imagejpeg($im,'',100); ImageDestroy($im); } } ?> build in another source: <img src="createImage.php?bild=somepicture.jpg">

« previous php.notes (#100814) next »