note 85614 added to function.imagecreatefromstring

From: Date: Tue, 09 Sep 2008 02:04:19 +0000
Subject: note 85614 added to function.imagecreatefromstring
Groups: php.notes 
Request: Send a blank email to php-notes+get-144251@lists.php.net to get a copy of this message
The only way I managed to resolve the loading of image files from file data either on local site or from off-site protocols is as follows. I hope this saves someone else the two hours of debugging and looking for good examples. [PHP] <?php $sFile = "http://www.justgreatwine.co.uk/img/vineyard.jpg"; $imagedata = GetFileData($sFile); //load the file in 4k chunks /*=======THE OUTPUT=========*/ ob_start(); // assuming you have image data in $imagedata $length = strlen($imagedata); header('Last-Modified: '.date('r')); header('Accept-Ranges: bytes'); header('Content-Length: '.$length); header('Content-Type: image/jpeg'); print($imagedata); ob_end_flush(); /*======FUNCTIONS USED======*/ function GetFileData($sFilePath){ $fp = fopen($sFilePath, 'rb') or die('404! Unable to open file!'); $buf = ''; while(!feof($fp)){ $buf .= fgets($fp, 4096); } fclose($fp); return $buf; //returns False if failed, else the contents up to FileSize bytes. } ?> [/PHP] ---- Server IP: 69.147.83.197 Probable Submitter: 90.195.29.23 ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromstring.php Edit -- https://master.php.net/note/edit/85614 Del: integrated -- https://master.php.net/note/delete/85614/integrated Del: useless -- https://master.php.net/note/delete/85614/useless Del: bad code -- https://master.php.net/note/delete/85614/bad+code Del: spam -- https://master.php.net/note/delete/85614/spam Del: non-english -- https://master.php.net/note/delete/85614/non-english Del: in docs -- https://master.php.net/note/delete/85614/in+docs Del: other reasons-- https://master.php.net/note/delete/85614 Reject -- https://master.php.net/note/reject/85614 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144251) next »