Page 230 - Nodejs 교과서 개정2판
P. 230
multipart.html
<form id="form" action="/upload" method="post" enctype="multipart/form-data">
<input type="text" name="title" />
<button type="submit">업로드</button>
</form>
app.post('/upload', upload.none(), (req, res) => {
console.log(req.body);
res.send('ok');
});
ੌਸ স۽٘ೞ ঋওਵ۽ req.body݅ ઓפ
§ Ӓܿ NVMUFS ٜਝয
पઁ۽ NVMUFS ઁܳ पणೞҊ रݶ BQQ KTܳ җ э ࣻפ NVMUJQBSU IUNMب غج݀פ
app.js
...
httpOnly: true,
secure: false,
},
name: 'session-cookie',
}));
const multer = require('multer');
const fs = require('fs');
try {
fs.readdirSync('uploads');
} catch (error) {
console.error('uploads 폴더가 없어 uploads 폴더를 생성합니다.');
fs.mkdirSync('uploads');