0

I am soon to be building a node application which involves allowing the user to fill in a form and then save this information to a mongo database. As part of this process, the user needs to be able to upload multiple images related to the form data. The user will need to see a small preview of each image (along with ability to remove images) before submitting the form which saves the data to an object then uploads the images to the server.

I do not want to save the images to the database (but do on the server), but I do want to save their file paths to the related object. This is the first ever solo project I will be working on for a web build for a friend of mine so its really early days with my experience with Node. I am aware I have thrown myself in the deep end but am determined to succeed with this project.

My question to you all is: is this possible with node? If so, could someone give me some pointers on how to approach this i.e. any useful npm packages etc etc. Note: I am only looking for help with regards to the server side, not front-end. I hope I have not been too vague; thank-you all in advance.

c.gooderham94
  • 97
  • 1
  • 9
  • Take a look at this https://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded maybe it helps. – Lohmar ASHAR Feb 24 '18 at 21:05
  • Words of caution, accepting uploads directly to the file system can be dangerous. – John Pavek Feb 24 '18 at 21:08
  • @JohnPavek I totally appreciate this. The website would only have one user inputting data; the admin. To be able to access this form, they will only be able to access via an authenticated login using passport.js. Is there a safer alternative to uploading though? – c.gooderham94 Feb 24 '18 at 22:36
  • Thanks @LohmarASHAR. This would solve the previewing issue, but not how to upload the image and also how to save the URL to an object. – c.gooderham94 Feb 24 '18 at 22:40

0 Answers0