ios微信本地视频上传到服务器,ios本地视频wx.uploadFile上传
//上傳視頻
uploadVideo:function(){
let _this = this;
let list = ['camera', 'album'];
wx.showActionSheet({
itemList: ['拍攝視頻','從相冊選擇視頻','從視頻庫選擇視頻'],
success: function (res) {
if(res.tapIndex==0 || res.tapIndex==1){
wx.chooseVideo({
sourceType:[list[res.tapIndex]],
compressed:true,
maxDuration:app.globalData.isIos?60:180,
success:function(res){
_this.videoLink=null;
_this.setData({
videoUp:0
});
// 視頻上傳狀態(tài)
_this.videoUpStatus = true;
const uploadTask = wx.uploadFile({
url: app.globalData.baseUrl+'?r=mpupfile',
filePath: res.tempFilePath,
name: 'video',
header: {
'token': app.globalData.token,
'content-type': 'multipart/form-data'
},
formData:{
"test":"test"
},
success: function (res) {
console.log(res,'===')
let dat? = JSON.parse(res.data)
if(dat.code==1 && dat.data){
wx.showToast({
title: '上傳成功',
icon: 'none',
mask:true,
duration:2000
})
_this.setData({
videoLink:dat.data
})
}else if(dat.code==0){
wx.showToast({
title: dat.msg?dat.msg:'上傳失敗',
icon: 'none',
mask:true,
duration:2000
})
}
},
fail: function (err) {
wx.showToast({
title: '網(wǎng)絡(luò)出錯',
icon: 'none',
mask:true,
duration:2000
})
},
complete:function(){
_this.videoUpStatus = false;
}
})
uploadTask.onProgressUpdate((res) => {
_this.setData({
videoUp:res.progress
})
})
}
,fail:function(err){
console.log('選擇沒有用')
}
})
}else{
}
}
,fail:function(err){
console.log('fail',err)
}
})
},
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的ios微信本地视频上传到服务器,ios本地视频wx.uploadFile上传的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一些中文编程语言
- 下一篇: 活久见!大四学生发明文言文编程语言,脑洞