Browse Source

修复签章上传bug

laiguoran 2 years ago
parent
commit
d4da5b948c
1 changed files with 7 additions and 1 deletions
  1. 7 1
      app/controller/profile_controller.js

+ 7 - 1
app/controller/profile_controller.js

@@ -482,7 +482,8 @@ module.exports = app => {
                 const parts = ctx.multipart({ autoFields: true });
                 const paths = [];
                 let index = 0;
-                while ((stream = await parts()) !== undefined) {
+                stream = await parts();
+                while (stream !== undefined) {
                     // 判断用户是否选择上传文件
                     if (!stream.filename) {
                         throw '请选择上传的文件!';
@@ -497,6 +498,11 @@ module.exports = app => {
                     }
                     paths.push(filepath);
                     ++index;
+                    if (Array.isArray(parts.field.size) && index < parts.field.size.length) {
+                        stream = await parts();
+                    } else {
+                        stream = undefined;
+                    }
                 }
                 // 获取账号数据
                 const accountData = await ctx.service.projectAccount.getDataByCondition({ id: ctx.session.sessionUser.accountId });