I'm submitting a form that contains sometimes single, sometimes multiple images. However when I submit an image, say 1.jpg
, the console output from my node server is MS5qcGc=
. I assume that somehow the image isn't being sent through, only the text? How can I send through the entire image, and convert it to base64
?
Client
<form method="post">
<div class="form-group">
<label for="imgs">Images</label><input accept="image/*" multiple name="imgs" type="file">
</div>
</form>
Server
if (typeof req.body.imgs == "string") {
console.log(new Buffer(req.body.imgs).toString('base64'));
} else {
for ( i in req.body.imgs) {
console.log(new Buffer(req.body.imgs[i]).toString('base64'));
}
}
via maudulus
No comments:
Post a Comment