O'Reilly logo

Web Development with MongoDB and Node - Third Edition by Mithun Satheesh, Bruno Joseph D'mello

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Uploading an image

The next feature we will need to implement in our image controller is the logic to handle when a user submits an image Upload Image on the home page. Even though the form is on the home page of our app, we decided to house the logic to handle uploading within our image controller because logically, this makes the most sense (since this feature primarily has to do with images, and not the home page per se). This was purely a personal decision, and you can house the logic wherever you please.

You should note that the HTML for the form on the home page has its action set to /images, and its method is post. This perfectly matches the route we set up previously, where we listen for a post to the /images route and call the image ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required