videoFile:{file:{},filePath:'',fileName:String},
//选择视频文件
chooseVideo(){
var _this = this
uni.chooseVideo({
count:2,
sourceType: ['camera', 'album'],
success:function(res){
console.log("chooseVideo success ="+JSON.stringify(res))
var fileName = ''
if(res.name === undefined){
fileName = _this.getNameFromFilePath(res.tempFilePath);
console.log("undefined fileName ="+fileName);
}else {
fileName = new String(res.name);
console.log(" fileName ="+fileName);
}
_this.videoFile = {file: res.tempFile,filePath:res.tempFilePath,fileName:((new String(fileName)).split(".")[0])}
console.log("_this.videoFile ="+JSON.stringify(_this.videoFile))
},
fai:function(){
console.log("chooseVideo fail ="+JSON.stringify(res))
}
})
},
uploadFile(_file){
console.log("uploadFiles _file ="+JSON.stringify(_file))
var _this = this;
var successCallback = function(res){
console.log('uploadFile success '+JSON.stringify(res))
};
var failCallback = function(error){
console.log('uploadFile fail error = '+JSON.stringify(error))
}
var param = {url:"http://192.168.11.71:8080/upload/",file:{},name:_file.fileName,filePath:_file.filePath,success:successCallback,fail:failCallback}
if(_file.file !== undefined){
param.file = _file.file
}
uni.uploadFile(param)
}
2 个回复
DCloud_Android_DQQ
你用最新版本 3.1.19试试
6***@qq.com (作者)
在文件物理地址前面加上file://,例如:
file:///storage/emulated/0/Android/data/com.sky.libapp/apps/UNIB0EC99A/temp/compress_video_1824232.mp4
文档没有说明这样的操作,自己试出来的