小程序端:
const Uploader = require('miniprogram-file-uploader').default
if(typeof(Uploader)!=='undefined' && Uploader.isSupport()){
wx.chooseVideo({
sourceType:['album','camera'],
compressed:false,
maxDuration:60,
camera:'back',
success:(res)=>{
console.log(res)
const uploader = new Uploader({
tempFilePath:res.tempFilePath,
totalSize:res.size,
chunkSize:1024*512,
testChunks:false,
fileName:'file',
uploadUrl:app.www+'/Wxapp/Multiple/partFile',
mergeUrl:app.www+'/Wxapp/Multiple/mergeFile'
})
uploader.upload()
uploader.on('complete',(res)=>{
console.log('upload complete',res)
})
uploader.on('success',(res)=>{
console.log('upload success',res)
})
uploader.on('fail',(res)=>{
console.log('fail',res)
})
uploader.on('progress',(res)=>{
console.log('progress',res)
})
}
})
}
后端:
我用了file_get_contents('php://input') $_FILES 等都无法获取二进制流
miniprogram-file-uploader 小程序多个大文件上传示例
服务端采用的nginx+php
链接:https://pan.baidu.com/s/1mJpWdbETfzYlnpaRKlH1jw 提取码:iq8r