Re: Problems with images..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 2008-11-03 14:43:43, schrieb Anders Norrbring:
> I've been staring myself blind, so now I don't get anywhere, please do
> advice..
> 
> I have a web page printed with PHP, in a table I need to display images that
> are stored in a SQL DB.
> Getting the images into variables isn't an issue at all, but how do I output
> it?
> This is what I want to accomplish:
> 
> <tr><td>Current image:</td><td> - THE IMAGE HERE - </td></tr>

In the Website:

    <tr><td>Current image:</td><td><img src="/?image=foo"></td></tr>

where I assume, you have a table called "imgstore" with three columgs of
"name", "type" and "image_data" and in the script:

if ($_GET['image'] != '') {

  $connect="host=localhost dbname=imgstore user=foo password=bar";
  $link=pg_connect($connect);

  $query="SELECT image_data,type FROM images WHERE name=$_GET['image']";
  list($image_data, $type=pg_query($query, $link);

  header("Content-Type: image/$type; name=$_GET['image']");
  header(2Content-Disposition: inline; filename=$_GET['image']");
  echo $image_data;

  pg_close($link);
  exit();
}

where $type it for example "jpeg" or "png" and $image_data the blob  you
fetched from your database.

ATTENTION:  Please sanitize it sonce this is ONLY an EXAMPLE.

Thanks, Greetings and nice Day/Evening
    Michelle Konzack
    Systemadministrator
    24V Electronic Engineer
    Tamay Dogan Network
    Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
+49/177/9351947    50, rue de Soultz         MSN LinuxMichi
+33/6/61925193     67100 Strasbourg/France   IRC #Debian (irc.icq.com)

<<attachment: signature.pgp>>


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux