how to store small images (< 2 MB)in mongodb and display the image on webpage without downloading it?
Asked
Active
Viewed 1,060 times
-1
-
1How is *"display the image on webpage without downloading it"* supposed to work? – Filburt Oct 05 '17 at 17:00
-
If one user uploads a image I will save it in database and for other users that image should be displayed – harish chava Oct 05 '17 at 17:08
-
Displaying an image on a web page inevitably downloads it. – Filburt Oct 05 '17 at 17:23
1 Answers
2
You can save it as base64 image. Base64 images is represented as string. So you can easily save and retrieve it. You will encode(in front-end) and save images as string. When you retrieve it to your front-end, you will decode and display it.

barbakini
- 3,024
- 2
- 19
- 25
-
I have encoded the image using Java **mime encoder**, But while decoding the Base64 string the image is being downloaded, any help? – harish chava Oct 05 '17 at 18:05
-
What are you using for frontend? you should pass encoded image as string to frontend and decode the string there. – barbakini Oct 05 '17 at 18:17
-
html, How can I show image without downloading from decoding string ?? to which data type we need to convert that string before displaying ? – harish chava Oct 05 '17 at 18:33
-
1