zhangershi

导航

 

上传视频可以使用uni.app里面的api

 

let self = this;
uni.chooseVideo({
count: 1,
sourceType: ['camera', 'album'],
success: function(res) {

console.log(res)
self.showVideo = true
self.addVideo = false
self.src = res.tempFilePath;
console.log(res.tempFilePath)
console.log(self.src)
console.log(self.userInfo.token)
uni.uploadFile({
// 需要上传的地址
url: 'xxxxxxxxxxx', //接口地址
// filePath 需要上传的文件
filePath: self.src,
name: 'file',
header: {
'token': self.userInfo.token, // from data
},
success: (res) => {
console.log(res)
let ret = JSON.parse(res.data);
console.log(ret)
self.form.videos = ret.data.fullurl
console.log(self.form.videos)
},
file: (err) => {
console.log(res)
}
});
}
});

posted on 2023-07-01 15:02  张二十  阅读(38)  评论(0编辑  收藏  举报