Hi, we want to build dynamic pages from a database (in our test lab is MS- Access via ODBC) table with a BINARY field (say imgfld) filled with image in raw (binary not OLE!) (JPEG/GIF, ecc) and other fields. (As for example may be an "employees card list" where we need to show peoples portrait and a table row describe all the information for a person included his/her photo.) The code we try was (suppose getTable1 as method to list all fileds in table) 'listCards': .... <!--#in getTable1 --> Name: <!--#var nameFld--> Address: <!--#var addressFld--> .... <img src="<!--#var imgFld -->"> .... <!--#/in> .... but this is wrong because the 'src' attribute of the 'img' HTML tag want the addres of the image not the image directly! So we have the right image (the object imgFld) but we can't use it! We need a way to get the "HTTP address" of the image object (that named 'imgFld' in this name space) in current tuple returned from getTable1 method when rendering the DTML tags in 'listCards'. Any suggest? Giovanni Coi ---------------------------------------------------------- Prometeo srl - The Software Experience Coi Giovanni Voice : +39 (041)5701366 Via Giudecca 15 Fax : +39 (041)5701005 30035 MIRANO (VE) - ITALY e-mail: coi@prometeo.it http://www.prometeo.it ----------------------------------------------------------
At 09:18 13/09/99 , Coi Giovanni wrote:
Hi,
we want to build dynamic pages from a database (in our test lab is MS- Access via ODBC) table with a BINARY field (say imgfld) filled with image in raw (binary not OLE!) (JPEG/GIF, ecc) and other fields. (As for example may be an "employees card list" where we need to show peoples portrait and a table row describe all the information for a person included his/her photo.)
The code we try was (suppose getTable1 as method to list all fileds in table)
'listCards':
.... <!--#in getTable1 --> Name: <!--#var nameFld--> Address: <!--#var addressFld--> .... <img src="<!--#var imgFld -->"> .... <!--#/in> ....
but this is wrong because the 'src' attribute of the 'img' HTML tag want the addres of the image not the image directly! So we have the right image (the object imgFld) but we can't use it!
We need a way to get the "HTTP address" of the image object (that named 'imgFld' in this name space) in current tuple returned from getTable1 method when rendering the DTML tags in 'listCards'.
You want a separate method that will only return the imgFld data, and sets the Content-Type of the data returned: <!--#call "RESPONSE.setHeader('Content-Type', 'image/gif')"--> <!--#in getTable1--><!--#var imgFld--><!--#/in--> Note that you may have to put things on one line to avoid extraneous whitespace (you can put breaks within DTML tags). Also note, that I haven't done this myself, and you might run into limits of the DA (like, not supporting BINAIRY fields). And, I assume your image data is always a GIF. If it is something else, adjust the Content-Type accordingly. You may have to pull this from the DB and set it dynamically. Then call have the browser call this method from the SRC attribute of the IMG tag: <!--#in getTable1 --> Name: <!--#var nameFld--> Address: <!--#var addressFld--> .... <img src="fromDBImg?id=<!--#var id-->"> .... <!--#/in> where "id=<!--#var id-->" is the information that getTable1 needs to pull the proper image from the database. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (2)
-
Coi Giovanni -
Martijn Pieters