页面
<view class="page-body-info">
<view class="image-plus-text" bindtap="chooseVideo">添加视频</view>
</view>
js控制
//上传视频
chooseVideo: function() {
var that = this
wx.chooseVideo({
success: function(res) {
that.setData({
src: res.tempFilePath,
})
var filep = res.tempFilePath
//向服务器端上传图片
wx.uploadFile({
url: app.globalData.baseUrl + 'User/upload1',
filePath: filep,
header: {
'content-type': 'multipart/form-data'
},
name: 'file',
formData: {
'token': wx.getStorageSync('token')
},
success: function (res) {
console.log(res)
}
});
}
})
},