On 10-Mar-2003 Philip J. Newman wrote: > If i was to use PHP to call all my images from out side the wwwroot, dose > anyone have a method that they use? >
show.php --------- <?php $rcsid='$Id: show.php,v 1.1 2002/02/14 21:20:26 dread Exp dread $'; // $Log: show.php,v 2002/02/14 21:20:26 dread $ // Revision 1.1 dread // Initial revision // error_reporting(0); // where is the base directory of the images? $imgdir='/usr/local/private/image'; // Allow a sub-directory from $imgdir? $allowpath= 0; // Allow searching for extention ? *not implemented* $allowsearch= 0; $mimetype=array( 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', // 'avi' => 'video/avi', 'avi' => 'video/x-msvideo', 'wmv' => 'video/x-ms-wmv', 'asf' => 'video/x-ms-asf', 'png' => 'image/png' ); if (! isset($id)) die('no id.'); $id= urldecode($id); $id= str_replace('../', '', $id); // fix the dodgy stuff $id= trim($id); if (! ($allowpath) ) $id= basename($id); $ext= substr(strrchr($id, '.'), 1); $path= $imgdir .'/' .$id; if ($handle= fopen($path, 'r')) { Header('Content-type: ' .$mimetype[$ext]); Header("Content-Disposition: inline; filename=" .basename($id)); fpassthru($handle); fclose($handle); } ?> call it as 'show.php?id=secretimg.jpeg' or use IMG SRC="show.php?id=secretimg.jpeg" Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php