将获取的图片转base64字符串
一处代码需要将通过WinHttp.WinHttpRequest.5.1控件中POWINHTTP.RESPONSEBODY获取的图片再次转发出去,对方接收的是图片base64字符串,如何处理?
转发图片.rar
(1005 Bytes)
PUBLIC YZMZF,YZMTPZFCLEAR
DECLARE Sleep IN kernel32 INTEGER dwMilliseconds
POWINHTTP = CREATEOBJECT("WinHttp.WinHttpRequest.5.1")
POWINHTTP.SETTIMEOUTS(0,3000,3000,3000)
POWINHTTP.OPTION(0)="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0)"
POWINHTTP.OPEN("GET", "https://base., .F.) && 读取验证码
POWINHTTP.SEND()
IF POWINHTTP.STATUS = 200
YZMTPZF=POWINHTTP.RESPONSEBODY
&&&&&& 需要将此处获取到的验证码图片转为base64字符串转发出去
DELETE FILE YZMTP.JPG
STRTOFILE(YZMTPZF,"yzmtp.jpg")
OFORM1=NEWOBJECT("form1")
OFORM1.IMAGE1.PICTUREVAL=YZMTPZF && 更新验证码图片
OFORM1.REFRESH
OFORM1.SHOW
?YZMZF
ENDIF
DEFINE CLASS FORM1 AS FORM
TOP = 0
LEFT = 0
HEIGHT =54
WIDTH = 220
SHOWWINDOW = 1
DOCREATE = .T.
CAPTION = "请输入验证码"
WINDOWTYPE = 1
NAME = "form1"
ALWAYSONTOP=.T.
AUTOCENTER=.T.
BORDERSTYLE=0
CLOSABLE=.F.
CONTROLBOX=.F.
ADD OBJECT IMAGE1 AS IMAGE WITH ;
TOP = 3, ;
LEFT = 3, ;
HEIGHT = 46, ;
WIDTH = 120, ;
PICTUREVAL=YZMTPZF,;
STRETCH=1,;
NAME="Image1"
ADD OBJECT TEXT1 AS TEXTBOX WITH ;
TOP = 3, ;
LEFT = 123, ;
HEIGHT = 40, ;
WIDTH = 60, ;
ENABLED = .T., ;
FONTSIZE=12,;
MAXLENGTH=5,;
NAME = "text1"
PROCEDURE TEXT1.KEYPRESS
LPARAMETERS NKEYCODE, NSHIFTALTCTRL
IF NKEYCODE=13 THEN
m.YZMZF=ALLTRIM(THISFORM.TEXT1.VALUE)
THISFORM.RELEASE
ENDIF
ENDDEFINE
[此贴子已经被作者于2022-6-17 08:56编辑过]