Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Express.js Mongoose - Form File Upload

Hello everyone,

I am having a problem pin-pointing the best approach to file upload using mongoose and express.js

I have a form which you enter the name of an item and a couple of photos of that image and i want to save this information into the database (mongoDB) somehow.

Please help... :'(

I use node.js v8.3.0

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Tobi;

Are you wanting to save the images themselves into a MongoDB database? It is more common to save the photos to disk and then store the path to the specific file in the database.

It is possible to store the images themselves inside MongoDB, but remember that there is a size limit on each document which may pose some issues depending on image size. There are ways around that, however, with utilizing GridFS to store the data, but that adds more complexity to the project.

Post back if you have further questions about your schema design.

Ken