VFPBS 猫框直接将SQL image字段变成图片输出

2023-09-11 17:57:35 浏览数 (2)

代码很简单

itm_image为image字段

itm_fname为图片文件名

代码语言:javascript复制
Define Class ctl_image As SESSION
  Procedure getfile
     cfile=HttpQueryParams2("file")
    
     CURSORSETPROP("MapBinary",.t.,0)
     
     TEXT TO lcSQLCmd NOSHOW TEXTMERGE 
     SELECT  itm_image FROM temp_itm_mstr_pic WHERE itm_fname=?cfile
     ENDTEXT 
     
     oDBSQLHelper=NEWOBJECT("MSSQLHelper","MSSQLHelper.prg")
     IF oDBSQLHelper.SQLQuery(lcSQLCmd,"temp_itm_mstr_pic")<0
       RETURN ""
     ENDIF 
     _currentcode="UTF-8"
     setContentType("image/png")
     RETURN "" temp_itm_mstr_pic.itm_image
  ENDPROC 
ENDDEFINE   

浏览器调用

http://127.0.0.1:801/ctl_image.fsp?proc=getfile&file=文件名

0 人点赞