I have a mean-stack application. I want to implement a button by which users could upload a thumbnail image, and the thumbnails will be saved in the server, then any page will be able to load a thumbnail by its link.
I have followed this video and decided to use multer
.
So, in the angularjs html page, I have added:
<form method="post" enctype="multipart/form-data">
<input type="file" name="myimage" ></input>
<input type="submit" name="submit" value="submit"></input>
</form>
And I have created a new folder uploads
under the existing public
folder. I have installed multer
, and in the back-end I have added:
var multer = require('multer');
var upload = multer({ dest: 'public/uploads/' })
router.post('/', upload.any(), function (req, res, net) {
console.log(JSON.stringify(req.files))
res.send(req.files)
});
As a result, by clicking on the Choose file
button I can choose a local file. However, clicking on submit
leads to nothing; no log or error message is shown in the front-end or back-end.
Does anyone know what I am missing? Should I do something in the controller to manually send the request to the server?
via SoftTimur
No comments:
Post a Comment