Re: Unable to display images on browser

From: Date: Fri, 01 Mar 2002 22:08:25 +0000
Subject: Re: Unable to display images on browser
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-86852@lists.php.net to get a copy of this message
if u have the data stored in the DB, just chuck the data out, with the correct mime-type header.. Andrew ----- Original Message ----- From: "Narvaez, Teresa" <Teresa.Narvaez@DynCorp.com> To: <joakim.andersson@cybercom.se>; <php-general@lists.php.net> Sent: Friday, March 01, 2002 8:41 PM Subject: RE: [PHP] Unable to display images on browser > Hello, > Thanks for your responses; however, I do not think I have the gd > libraries installed because ImageCreateFromString() was not found. I will > install it. > > I have a question: I can display the PNG or GIF image using the > browser. So Why do I need the GD library? Since I store the mime type in > the database I think that a call to header() to tell the browser what type > of mime-type is coming from the database should sufice. Also, I want to > store any type of binary data into my database (PNG, GIF, word, JPG, etc) Am > I missing something? > > Thanks, > -Teresa > > > -----Original Message----- > From: joakim.andersson@cybercom.se [mailto:joakim.andersson@cybercom.se] > Sent: Thursday, February 28, 2002 4:12 AM > To: php-general@lists.php.net > Subject: RE: [PHP] Unable to display images on browser > > > You need to insert the following lines after this line: > Header("Content-type: image/gif"); > > $im = ImageCreateFromString ($fileContent); > ImageGif ($im); > > and then remove this line: echo $fileContent; > That should do it. > > /Joakim > > -----Original Message----- > From: Narvaez, Teresa [mailto:Teresa.Narvaez@DynCorp.com] > Sent: Wednesday, February 27, 2002 8:32 PM > To: 'joakim.andersson@cybercom.se'; php-general@lists.php.net > Subject: RE: [PHP] Unable to display images on browser > > > Hello, Thanks for your help. This is what I have for file1.php and > ddownloadfile.php. What I want is to click on "Donwnload now" link and be > able to get the file out of the database and display it on the browser. > Thank you in adavance, -Teresa > file1.php > ----------- > <?php > while ($row = mysql_fetch_array($result)) > { > ?> > SOME_HTLM_CODE_TO_DISPLAY_DB_FIELDS_GOES_HERE; > // <img src=\"ddownloadfile.php?fileId=<?php echo $row["PicNum"]; ?>\" > > > <a href="ddownloadfile.php?fileId=<?php echo $row["PicNum"]; > ?>" > > Download Now > </a></font> > </td> > </tr> > <?php > > > ddownloadfile.php > ------------------ > <? > $dbQuery = "Select PicNum, size, type, description, Image"; > $dbQuery .= " FROM Images WHERE PicNum = $fileId"; > $result = mysql_query($dbQuery) > or die ("Could not get file list: " . mysql_error() ); > echo "Sent Query successfully<br>"; > if ( mysql_num_rows($result) == 1) > { > $fileType = @mysql_result($result,0, "type"); > $fileContent = @mysql_result($result, 0, "Image"); > $filedesc = @mysql_result($result,0, "description"); > $filenum = @mysql_result($result,0, "PicNum"); > Header("Content-type: image/gif"); > echo $fileContent; > } > else > { > echo "Record does not exist"; > } // else > ?> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#86852) next »