반응형
npm i express-fileupload
const fileRoute = express();
const fileUpload = require('express-fileupload');
fileRoute.use(fileUpload({
createParentPath: true,
defCharset: 'utf8',
defParamCharset: 'utf8',
debug: true
}));
fileRoute.post("/upload", async (req, res, next) => {
// buffer, encoding, fieldname , mimetype , originalname ,size
const files = req.files
const result = await FileUpload(null,files);
files값
{
name: "원본 파일명.png",
data: buffer,
size: 1113653,
encoding: "7bit",
tempFilePath: "",
truncated: false,
mimetype: "image/png",
}
//or
[{...}, {... }]
반응형
'JAVASCRIPT' 카테고리의 다른 글
(js) next js 에러 (0) | 2023.05.03 |
---|---|
(javascript) 암호화 정리중 .. (0) | 2023.02.20 |
(js) 파일 업로드 , 다운로드 (0) | 2023.01.10 |
(javascript)상속 (0) | 2022.06.27 |
(javascript)이스케이프 문자열 치환 (0) | 2022.05.12 |