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 關注
- 201 瀏覽
添加回答
舉報