uni-app uni.uploadFile上传10MB左右的文件无法上传
uni-app uni.uploadFile上传10MB左右的文件无法上传 产品分类:uniapp/H5
| 项目 | 内容 |
|---|---|
| PC开发环境操作系统 | Windows |
| PC开发环境操作系统版本号 | windows10 |
| HBuilderX类型 | 正式 |
| HBuilderX版本号 | 3.3.10 |
| 浏览器平台 | 微信内置浏览器 |
| 浏览器版本 | 公众号,微信版本8.0.19 |
| 项目创建方式 | HBuilderX |
bug描述:
uni.uploadFile上传10MB左右的文件就没办法上传,传即使KB的就没问题
示例代码:
/**文件上传**/
uploadFile: function(imgUrl, imgPath) {
// 返回promise
return new Promise((resolve, reject) => {
pub.doShowLog('####request file start param:',{url:imgUrl,data:imgPath});
uni.uploadFile({
url: imgUrl, // 后端api接口
filePath: imgPath, // uni.chooseImage函数调用后获取的本地文件路劲
name: 'file', //后端通过'file'获取上传的文件对象
success: res => {
res.data = JSON.parse(res.data);
pub.doShowLog('####request file end success:',{url:imgUrl,data:res});
checkRstSuccess(res);
// 将结果抛出
resolve(res);
},
fail: function(err) {
pub.doShowLog('###end file fail reason:',{url:imgUrl,errorMsg:err},'error');
resolve(err);
},
});
});
},
操作步骤:
/**文件上传**/
uploadFile: function(imgUrl, imgPath) {
// 返回promise
return new Promise((resolve, reject) => {
pub.doShowLog('####request file start param:',{url:imgUrl,data:imgPath});
uni.uploadFile({
url: imgUrl, // 后端api接口
filePath: imgPath, // uni.chooseImage函数调用后获取的本地文件路劲
name: 'file', //后端通过'file'获取上传的文件对象
success: res => {
res.data = JSON.parse(res.data);
pub.doShowLog('####request file end success:',{url:imgUrl,data:res});
checkRstSuccess(res);
// 将结果抛出
resolve(res);
},
fail: function(err) {
pub.doShowLog('###end file fail reason:',{url:imgUrl,errorMsg:err},'error');
resolve(err);
},
});
});
},
预期结果:
/**文件上传**/
uploadFile: function(imgUrl, imgPath) {
// 返回promise
return new Promise((resolve, reject) => {
pub.doShowLog('####request file start param:',{url:imgUrl,data:imgPath});
uni.uploadFile({
url: imgUrl, // 后端api接口
filePath: imgPath, // uni.chooseImage函数调用后获取的本地文件路劲
name: 'file', //后端通过'file'获取上传的文件对象
success: res => {
res.data = JSON.parse(res.data);
pub.doShowLog('####request file end success:',{url:imgUrl,data:res});
checkRstSuccess(res);
// 将结果抛出
resolve(res);
},
fail: function(err) {
pub.doShowLog('###end file fail reason:',{url:imgUrl,errorMsg:err},'error');
resolve(err);
},
});
});
},
更多关于uni-app uni.uploadFile上传10MB左右的文件无法上传的实战教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复
更多关于uni-app uni.uploadFile上传10MB左右的文件无法上传的实战教程也可以访问 https://www.itying.com/category-93-b0.html
额。。抓错误代码啊。

