wxml:
<button bindtap='imageUpload'>上传图片</button>
<button bindtouchstart="startRecode" bindtouchend="endRecode" class="cxbtn">上传音频</button>
<button bindtap='videoUpload'>上传视频</button>
js:
imageUpload(){
var that = this;
//选择图片
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
that.upImgs(tempFilePaths[0],0);
}
})
},
//上传图片
upImgs: function (imgurl, index) {
var that = this;
wx.uploadFile({
url: api.image_upload,//
filePath: imgurl,
name: 'file',
header: {
'cont