2 回答

TA贡献1880条经验 获得超4个赞
谢谢正如你所说,我解决了这个问题:
// 获取验证码图片
func (this App) GetSecurityCode(timestamp int64) r.Result {
// 时间戳参数,第一次加载为1,后续加载为当前的时间戳,可以用来验证客户端刷新频率
// 如:刷新频率过高,直接限制当前客户端等
//fmt.Println("GetSecurityCode", timestamp)
d := make([]byte, 4)
s := base.NewLen(4)
ss := ""
d = []byte(s)
for v := range d {
d[v] %= 10
ss += strconv.FormatInt(int64(d[v]), 32)
}
this.Session["securityCode"] = ss
fmt.Println(this.Session["securityCode"])
//this.Response.Status = http.StatusOK
//this.Response.ContentType = "image/png"
buff := &bytes.Buffer{}
base.NewImage(d, 100, 40).WriteTo(buff)
return this.RenderBinary(buff, "img", r.Attachment, time.Now())
}
- 2 回答
- 0 关注
- 202 浏览
添加回答
举报