Page 229 - Nodejs 교과서 개정2판
P. 229
<input type="file" name="many" multiple />
<input type="text" name="title" />
<button type="submit">업로드</button>
</form>
ٜਝযח TJOHMF न BSSBZ۽ Үפ
app.post('/upload', upload.array('many'), (req, res) => {
console.log(req.files, req.body);
res.send('ok');
});
স۽٘ Ѿҗب SFR GJMF न req.files ߓৌী ٜয णפ
ੌਸ ৈ۞ ѐ স۽٘ೞ݅ input కӒա ಬ ؘఠ ఃо ܲ ҃ীח GJFMET ٜਝযܳ ࢎਊפ
multipart.html
<form id="form" action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="image1" />
<input type="file" name="image2" />
<input type="text" name="title" />
<button type="submit">업로드</button>
</form>
GJFMET ٜਝয ੋࣻ۽ input కӒ nameਸ пп णפ
app.post('/upload',
upload.fields([{ name: 'image1' }, { name: 'image2' }]),
(req, res) => {
console.log(req.files, req.body);
res.send('ok');
},
);
স۽٘ Ѿҗب req.files.image1 req.files.image2ী пп ٜয णפ
ౠࣻೠ ҃݅ ੌਸ স۽٘ೞ ঋҊب ݣ౭ ഋधਵ۽ স۽٘ೞח ҃о णפ Ӓۡ ٸח OPOF
ٜਝযܳ ࢎਊפ