小程序
小游戏
企业微信
微信支付
扫描小程序码分享
wx.uploadFile始终报错。
uploadFile:fail upload fail:-101 :net::ERR_CONNECTION_RESET。后台业务域名及wx.request,wx.uploadFile等域名均已经正确设置。
两天之前一直正常,前天开始出现异常,截图如下:
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
我也碰到这个问题,现在官方有回复吗,能否给下解决方案
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
/**
* minio
*/
uploadFileMinio: function (e) {
var that = this;
wx.chooseMessageFile({
count: 1,
type: "file",
success: function (res) {
const tempFilePaths = res.tempFiles;
// 如果文件超限
var curTempFile = tempFilePaths[0];
// 判断文件是否支持
var pointItems = curTempFile.name.split(".");
console.log("curTempFile.name=" + curTempFile.name);
if (pointItems.length > 0) {
var fileExt = pointItems[pointItems.length - 1];
fileExt = fileExt.toUpperCase();
console.log("fileExt=" + fileExt);
console.log("fileExt=" + that.data.uploadFileExt.indexOf(fileExt));
if (that.data.uploadFileExt.indexOf(fileExt) < 0) {
wx.showModal({
title: app.globalData.APP_MSG_TITLE,
content: '仅支持' + that.data.uploadFileExt + '文件类型',
confirmColor: app.globalData.CONFIRM_COLOR,
showCancel: false,
if (res.confirm) {
return;
}
})
};
if (curTempFile.size > that.data.uploadMaxSize.bytes) {
that.webGuide();
// 推送文件
that.pushFile(tempFilePaths);
},
* 推送文件
pushFile: function (tempFilePaths, callback) {
var curFile = tempFilePaths[0];
var user = that.data.userInfo;
var uploadedFile = {};
uploadedFile.fileName = curFile.name;
uploadedFile.fileSize = curFile.size;
uploadedFile.fileTime = curFile.time;
uploadedFile.isCloud = false;
uploadedFile.isImage = false;
uploadedFile.owned = "PRIVATE";
uploadedFile.status = 1;
console.log("准备上传的文件=", curFile);
// 加载中
util.isLoading();
// 加载数据
wx.uploadFile({
url: app.globalData.g_conversionServer + 'aop-uploadFile.php',
filePath: curFile.path,
name: "file",
formData: {
openid: user._openid,
fileName: curFile.name
console.log("pushFile.res=", res);
if (res.statusCode == 200) {
var data = JSON.parse(res.data);
if (data.result == true) {
uploadedFile.accessPdfPath = data.accessPdfPath;
uploadedFile.miniServerUrl = data.miniServerUrl;
uploadedFile.baseBucket = data.baseBucket;
uploadedFile.tenantBucket = data.tenantBucket;
uploadedFile.srcFile = data.srcFile;
uploadedFile.srcFileExt = data.srcFileExt;
uploadedFile.pdfFile = data.pdfFile;
uploadedFile.pdfFileSize = parseInt(data.pdfFileSize);
uploadedFile.txtFile = data.txtFile;
uploadedFile.txtFileSize = parseInt(data.txtFileSize);
uploadedFile.pages = data.pages;
uploadedFile.printCount = 0;
uploadedFile.createBy = user._openid;
uploadedFile.createTime = util.getCurrentDatetime();
uploadedFile.updateBy = user._openid;
uploadedFile.updateTime = util.getCurrentDatetime();
// 输出日志
console.log("uploadedFile=", uploadedFile);
// 添加到数据库
that.addFile(uploadedFile, function () {
that.bindGoTop();
});
fail: function (err) {
console.error("wx.uploadFile.err=", err);
content: '有异常:' + err.errMsg + ',请稍等',
complete: res => {
// 加载完成
util.loadingDone();
// 结束加载
if (typeof callback === "function") {
callback();
* 添加到云数据库
addFile: function (uploadedFile, callback) {
// 添加
db.collection("uploaded_files").add({
data: uploadedFile
}).then(res => {
console.log("addFile.res=", res);
that.loadFile(res._id);
// 如果有回调
以上是我写的逻辑,一些变量我就不一一写实了。红色为文件上传到php服务器(www.aoprint.cn)
你好,请提供下完整的代码。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
我也碰到这个问题,现在官方有回复吗,能否给下解决方案
/**
* minio
*/
uploadFileMinio: function (e) {
var that = this;
wx.chooseMessageFile({
count: 1,
type: "file",
success: function (res) {
const tempFilePaths = res.tempFiles;
// 如果文件超限
var curTempFile = tempFilePaths[0];
// 判断文件是否支持
var pointItems = curTempFile.name.split(".");
console.log("curTempFile.name=" + curTempFile.name);
if (pointItems.length > 0) {
var fileExt = pointItems[pointItems.length - 1];
fileExt = fileExt.toUpperCase();
console.log("fileExt=" + fileExt);
console.log("fileExt=" + that.data.uploadFileExt.indexOf(fileExt));
if (that.data.uploadFileExt.indexOf(fileExt) < 0) {
wx.showModal({
title: app.globalData.APP_MSG_TITLE,
content: '仅支持' + that.data.uploadFileExt + '文件类型',
confirmColor: app.globalData.CONFIRM_COLOR,
showCancel: false,
success: function (res) {
if (res.confirm) {
return;
}
}
})
return;
};
}
if (curTempFile.size > that.data.uploadMaxSize.bytes) {
that.webGuide();
return;
}
// 推送文件
that.pushFile(tempFilePaths);
}
})
},
/**
* 推送文件
*/
pushFile: function (tempFilePaths, callback) {
var that = this;
var curFile = tempFilePaths[0];
var user = that.data.userInfo;
var uploadedFile = {};
uploadedFile.fileName = curFile.name;
uploadedFile.fileSize = curFile.size;
uploadedFile.fileTime = curFile.time;
uploadedFile.isCloud = false;
uploadedFile.isImage = false;
uploadedFile.owned = "PRIVATE";
uploadedFile.status = 1;
console.log("准备上传的文件=", curFile);
// 加载中
util.isLoading();
// 加载数据
wx.uploadFile({
url: app.globalData.g_conversionServer + 'aop-uploadFile.php',
filePath: curFile.path,
name: "file",
formData: {
openid: user._openid,
fileName: curFile.name
},
success: function (res) {
console.log("pushFile.res=", res);
if (res.statusCode == 200) {
var data = JSON.parse(res.data);
if (data.result == true) {
uploadedFile.accessPdfPath = data.accessPdfPath;
uploadedFile.miniServerUrl = data.miniServerUrl;
uploadedFile.baseBucket = data.baseBucket;
uploadedFile.tenantBucket = data.tenantBucket;
uploadedFile.srcFile = data.srcFile;
uploadedFile.srcFileExt = data.srcFileExt;
uploadedFile.pdfFile = data.pdfFile;
uploadedFile.pdfFileSize = parseInt(data.pdfFileSize);
uploadedFile.txtFile = data.txtFile;
uploadedFile.txtFileSize = parseInt(data.txtFileSize);
uploadedFile.pages = data.pages;
uploadedFile.printCount = 0;
uploadedFile.createBy = user._openid;
uploadedFile.createTime = util.getCurrentDatetime();
uploadedFile.updateBy = user._openid;
uploadedFile.updateTime = util.getCurrentDatetime();
// 输出日志
console.log("uploadedFile=", uploadedFile);
// 添加到数据库
that.addFile(uploadedFile, function () {
that.bindGoTop();
});
}
}
},
fail: function (err) {
console.error("wx.uploadFile.err=", err);
wx.showModal({
title: app.globalData.APP_MSG_TITLE,
content: '有异常:' + err.errMsg + ',请稍等',
confirmColor: app.globalData.CONFIRM_COLOR,
showCancel: false,
success: function (res) {
if (res.confirm) {
return;
}
}
})
},
complete: res => {
// 加载完成
util.loadingDone();
// 结束加载
if (typeof callback === "function") {
callback();
}
}
});
},
/**
* 添加到云数据库
*/
addFile: function (uploadedFile, callback) {
var that = this;
// 添加
db.collection("uploaded_files").add({
data: uploadedFile
}).then(res => {
console.log("addFile.res=", res);
that.loadFile(res._id);
}).then(res => {
// 如果有回调
if (typeof callback === "function") {
callback();
}
});
},
以上是我写的逻辑,一些变量我就不一一写实了。红色为文件上传到php服务器(www.aoprint.cn)
你好,请提供下完整的代码。