【触动精灵将图片转成base64字符串后通过post方式上传给服务器】
生活随笔
收集整理的這篇文章主要介紹了
【触动精灵将图片转成base64字符串后通过post方式上传给服务器】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
觸動端的代碼
function OCR_Text(x1,y1,x2,y2)local url = "http://"--截圖保存snapshot("/sdcard/test"..".png",x1,y1,x2,y2);--local file = userPath().."/res/test.png"file = "/sdcard/test.png"txt = readFileString(file)--讀取文件內容,返回全部內容的 stringif txt then--dialog("文件內容:"..txt)else--dialog("文件不存在")end--需要下載 ts.so--local file = userPath().."/res/test.png"str = imageBase64(file)--發送的數據格式data = [[{"key": ["image"], "value": ["]]..str..[["]}]]--dialog(data,0)--status,header,content = http.post(url,{headers=header_send,params=body_send,opts={charset="gbk"}})status,header,content = http.post(url,{postdata = data ,opts={charset="utf8"}})--dialog(status,16)--dialog(header,16)--dialog(content,16)if status == 200 thentoast("成功",5)--dialog(header,6)--dialog(content,6)elsedialog("失敗")endreturn content end總結
以上是生活随笔為你收集整理的【触动精灵将图片转成base64字符串后通过post方式上传给服务器】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android预览界面编译出错,Andr
- 下一篇: 交通流理论3——交通流三大参数