图片上传

This commit is contained in:
chaosBreaking
2019-10-10 17:35:11 +08:00
parent 832b8f2f53
commit e04e097115
2 changed files with 15 additions and 1 deletions

View File

@@ -4,6 +4,12 @@ const MsgCode = require('../msgCode/msgCode.controller');
const changePwd = require('../sign/sign.controller').changePasswd;
const Crypto = require('../../utils/crypto');
const { parseForm } = require('../../utils/form');
const { USER_FILE_DIR: userFileDir } = require('../../../configSec.js');
const fs = require('fs');
if (!fs.existsSync(userFileDir)) {
fs.mkdirSync(userFileDir);
}
module.exports = {
changePwd,
@@ -147,7 +153,8 @@ module.exports = {
async verify (req, res) {
const { userId } = res.locals.user;
const form = await parseForm(req, {
uploadDir: `./userImages/${userId}`,
tag: userId,
uploadDir: userFileDir,
maxFileSize: 20 * 1024 * 1024, // 限制文件体积最大20m
keepExtensions: true,
encoding: 'utf-8'