1

I have been building a MEAN stack review application. I implemented Multer for the profile image uploading. I am successfully uploading images and saving them to MongoDB, however to see the image appear I need to restart the application.

I would like to be able to display the image on the page as soon as the image is successfully uploaded through Multer without restarting anything.

I am curious whether there is a simple method to implement this. Do I need a get request and possibly a page refresh?

Thanks for your help.

sharedev
  • 389
  • 2
  • 6
  • 21
  • 1
    i suggest you to use file reader to create preview . that why you don`t need to send it back to the client from the server – Amit Wagner Mar 06 '18 at 20:31
  • @AmitWagner Thanks for your response. Can you clarify on the file reader aspect? I'm currently reading my uploaded files based on their file path in the public folder, which makes me think that it needs to exist there after upload for me to display it on the page. – sharedev Mar 06 '18 at 20:33
  • 2
    you do it when the the user chose the image . its happen even before the file was uploaded you can see an example in this codepen link https://codepen.io/matt-west/pen/CfilG – Amit Wagner Mar 06 '18 at 21:01
  • thank you for your help! I found this example as well on showing previews in Angular 2: https://stackoverflow.com/questions/39074806/how-to-preview-picture-stored-in-the-fake-path-in-angular-2-typescript – sharedev Mar 06 '18 at 21:33

0 Answers0