×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
To begin using images, I needed to learn how to upload (using the new
feature in CGIDEV2), how to store in a BLOB and how to send the BLOB to
the browser. A couple of simple programs do the job, for production you
need to include "error checking".
I created a sample table:
CREATE TABLE QGPL.FOTOS(
IDENT CHAR(10) NOT NULL,
FOTO BLOB(2m) ,
CONSTRAINT QGPL.CLAVE_PRI_FOTOS
PRIMARY KEY(IDENT)
) RCDFMT F1
A program to show a jpg in the browser:
*****************************************************************
* Sample program to show in a browser a jpg image from a BLOB *
* Autor: Raul Jager - Paraguay *
* Feel free to copy and/or include in other application *
*****************************************************************
d ident s 10
d fotito s SQLTYPE( BLOB:200000)
d fotnull s 5i 0
d datos s 1000 varying
* Fields for CGIDEV
DnbrVars s 10i 0
DsavedQueryString...
D s 32767 varying
D NewLine c x'15'
/include cgidev2/qrpglesrc,prototypeb
/include cgidev2/qrpglesrc,usec
// ident is the key, no risk of sql injection for static SQL
exec sql select foto into :fotito :fotnull
from qgpl/fotos where ident = :ident;
// if the read succeds, show the image. (only jpg)
if sqlstate = '00000';
// to send other file types to the browser, you need to have
// a variable for "content type"
datos = 'Content-type: image/jpeg' +newline +newline;
WrtNoSection(%addr(datos)+2: %len(datos));
WrtNoSection(%addr(fotito_data): fotito_len);
// otherwise show the sqlstate
else;
datos = 'Content-type: text/html' +newline +newline +
'SQL dijo:' + sqlstate;
WrtNoSection(%addr(datos)+2: %len(datos));
endif;
wrtsection('*fini');
return;
Program to "upload" the images
*****************************************************************
* Sample program to upload a jpg image to a BLOB from the pc *
* Autor: Raul Jager - Paraguay *
* Feel free to copy and/or include in other application *
* when first called, it shows a form to select the pc file *
* Ok will upload the file, show it, and be ready for the next *
*****************************************************************
d ident s 10
d fotito s SQLTYPE( BLOB_file)
d datos s 1000 varying
DnbrVars s 10i 0
DsavedQueryString...
D s 32767 varying
D NewLine c x'15'
/include cgidev2/qrpglesrc,prototypeb
/include cgidev2/qrpglesrc,usec
/free
*inlr = *on;
// the "form" is in the cgidev directory, need to check error
GetHtmlIFS('/cgidev/html/get_jpg.xhtml': '<!-- _':' -->');
ClrHtmlBuffer();
NbrVars = ZhbGetInput(SavedQueryString:qusec);
ident = zhbGetVar('ident');
// no ident, just ask for the data...
if ident <> *blank;
fotito_name = zhbGetVar('imagen_tempfile');
fotito_nl = %len(%trim(fotito_name));
fotito_dl = *zero;
fotito_fo = SQFRD;
exec sql insert into qgpl/fotos
(ident, foto)
values(:ident, :fotito);
unlink(fotito_name);
endif;
// show the form every time it is called
datos = 'Content-type: text/html' +newline +newline;
WrtNoSection(%addr(datos)+2: %len(datos));
wrtsection('top');
// if some data was send show it
if ident <> *blank;
updHtmlVar('ident': ident);
updHtmlVar('state': sqlstate);
wrtsection('result');
endif;
wrtsection('pie *fini');
return;
The form from the IFS (I used /cgidev/htm directory for the sample)
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.