小程序 代码
choose_xsz_img(){
var that = this;
this.setData({
shadeShow: true
})
wx.chooseImage({
count: 1, // 默认9
sizeType: [ 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册album 还是相机camera,默认二者都有
success: function (res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
var tempFilePaths = res.tempFilePaths
//上传文件
wx.uploadFile({
url: baseURL+'/api/xcx/baidu/ocr/xsz/uploadimage',//请求接口地址
filePath: tempFilePaths[0],//图片路径,如tempFilePaths[0] 为第一张图片
name: 'image',
header: {
"Content-Type": "multipart/form-data"
},formData: {
'openid': app.globalData.openid
},
success: function (res) {
console.log(res);
that.setData({
shadeShow: false,xsz_state:1
})
},
fail: function (res) {
console.log(res);
},
complete: function (res) {
}
})
}
})
},后台接受openid代码
String openid =request.getParameter("openid");站长微信:xiaomao0055
站长QQ:14496453