RE: [PHP3] Database image display
[email protected] (Boaz Yahav) Fri, 9 Jun 2000 12:31:04 +0200
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <[email protected]> |
Check out these two articles : PHP, MySQL and images http://www.weberdev.com/index.php3?GoTo=ViewArticle.php3?ArticleID=6 Saving Images in MySQL http://www.weberdev.com/index.php3?GoTo=ViewArticle.php3?ArticleID=3 berber -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: Friday, June 09, 2000 12:45 AM To: PHP4BETA; PHP3 Subject: [PHP3] Database image display My problem is this: I have an image inside a database that I would like to display on the client browser. I've created a script that retrieves the data from inside the database. Now the problem is how to send the image back to the browser. I've come across with 2 solutions, one by the looking at the HTTP protocol and another by searching the PHP manual. -- 1st SOLUTION -- I've done a telnet to port 80 of a WWW server (both apache and IIS4) and requested an image. I've come to the conclusion that the server sends the image as it's binary data without any headers. Now, to implement this solution I need to instruct PHP not to send any headers. Sometime ago I have seen a thread message saying that it was **impossible** to do it because of the nature of PHP (script engine), but for PHP installed as a CGI. In this cenario PHP is installed as a module both in apache and ISS4. Now, is it possible to achive such a result? -- 2nd SOLUTION -- In the PHP manual, under 'Creating GIF images' section is presented this script: <?php Header("Content-type: image/gif"); $string=implode($argv," "); $im = imagecreatefromgif("images/button1.gif"); $orange = ImageColorAllocate($im, 220, 210, 60); $px = (imagesx($im)-7.5*strlen($string))/2; ImageString($im,3,$px,9,$string,$orange); ImageGif($im); ImageDestroy($im); ?> By looking at this I've come to the conclusion that it is an alternate way of sending images back to the client. Namely, by setting 'Content-type' I could send an image back to the client. Now, I've created a script that sets such a header and then outputs all binary data back to the client. Under these conditions, the browser (IE5 or Netscape4.51) fails to display the image, in such a way that keeps trying to retrieve more information from the server, i.e., does not stop to download the page. However, if I do a telnet to the server, the information is sent correctly (header and image data) and the connection is closed by the server. I've als tried to set the 'Content-Length' header to the image size, but the result is the same. Now, any clues on this? Thanks in advance. Pedro Miguel Negrao Malo | WWW: http://www.dee.fct.unl.pt/~pmm E-mail: [email protected] | alternate E-mail: [email protected] Phone: (+351+21)2948500 ext3740 | Fax: (+351+21)2957786 UNINOVA Institute | Inteligent Robotics Center Faculty of Science and Technology | New University of Lisbon 2825 Monte Caparica | PORTUGAL -- ---- Help us to find alien civilizations, join SETI@home effort at http://setiathome.ssl.berkeley.edu -- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to [email protected] To subscribe to the digest, e-mail: [email protected] To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: [email protected]