<h4>上传老师介绍视频</h4>
<div class="teacher-avatar">
<!-- <IntroduceTeacherVideo/> -->
<Button type="primary" icon="ios-search">
<label class="btn" for="teacherIntroductionVideo">上传老师介绍视频</label>
</Button>
<input type="file"
id="teacherIntroductionVideo"
style="position:absolute; clip:rect(0 0 0 0);"
accept="audio/mp4, video/mp4"
@change="uploadTeacherVideo($event)">
</div>
uploadTeacherVideo(e){
var file = e.target.files[0]
if (!/\.(mp4|avi)$/.test(e.target.value)) {
this.$Message.error({
content:'视频类型必须是.mp4、.avi中的一种',
duration:3
});
return false
}
let data = window.URL.createObjectURL(new Blob([e.target.result]))
let formdata = new FormData();
formdata.append('imgStream',data);
console.log('正在上传视频。。。')
this.uploadFileToQiniu(formdata);
},
uploadFileToQiniu(formdata){
this.$post(`${this.$url}/teacher/uploadFileToQiniu`,formdata)
.then(res=>{
if(res.data.success){
let hashKey = res.data.data;
this.avatarSrc = `${this.$qiniuImgUrl}/${hashKey.key}`;
this.$Message.success({
content:'上传成功!',
duration:3
});
}else{
this.$Message.error({
content:res.data.msg,
duration:3
});
}
})
.catch(err=>{
})
这样写好像报错
改成这样就OK了