I want to bring up a website that is a cosmetics project. and I want to create product info for them each product has an image that I make a URL for them and I want to use an ejs for them. ex: for a product for its image I want to write <%= product.img %> and the product image will show up and I don't know how to put a URL in the MongoDB database to when I type the ejs in .ejs file it will show up the image of the product. I search a lot in google all of them was for that user to upload an image on the website but I want to upload an image in my database and then use it with ejs file.
just store the image url in the database and then put that url in img tag src attribute. then it should show the image
You can convert images to base64 format then save them on your database.
Refer to the code below:
const fs = require('fs');
const contents = fs.readFileSync('/path/to/file.jpg', {encoding: 'base64'});
Related
Hello I have a question about uploading images to WinCC Unified V17 from my external db. The database contains the file path of the images. According to the following product, a specific image need to be chosen from the database and will be shown on the screen.
How can I dynamically call a file path from the database and show it as an image on my screen while the WinCC is running ?
Thanks in advance for your responses.
I am currently working on a project where I have to do a lookup page in node js. The lookup needs to lookup an id (entered in my rendered index.ejs file by the user) and display the information retrieved from a database. Information recieved includes the id, name, email, and a picture. So far I have figured out how to render text into the ejs file however I cannot find any information on how to live render an image from the server.js file. I've looked for ways to render an "" tag through the text so I can load it that way and I have looked for ways to render the image itself but have only been able to find tutorials on how to make a html file with a hard coded image inside, and render the whole file, which would not allow me to do the lookup. Can anyone suggest a way to do this and/or link me to somewhere where I can get the information on how to do this?
.
Key details (as I do not know what you need to know):
File type: ejs
File render type: res.render()
Main file: server.js
.
Im sorry if this isnt much to go on as I am new to node js.
Thanks
If you have full image in the database, then
There is pic attribute to the res.render in express.js
An example of how you can render image is below.
var pic = "./public/images/"+collection_id+"/"+photo_id+".png"; //(You can get the image from database and assign here)
var comments = "bla bla bla";
res.render('index', { title: 'Viewer' , pic: pic , comments: comments } );
In your ejs:
<img src='<%= pic %>' />
I have used cloudinary. I have uploaded an image to cloudinary and I want to get that image status from cloudinary that it is uploaded or not using cloudinary URL or from image name.
I am using jQuery and I want to display a list of images with their status uploaded on cloudinary. I have URL stored in my database.
Can anyone have an idea on this?
You can utilize the upload response (JSON) for this matter, as described here.
For a shopping site, I need to add product via file upload.
I have returned the data entered from csv as array. But now I need the images too. But in Csv only the image names will be given.
I need the image content in db. My images are stored as long blob data.
How can I get the image content?
Here i am using CameraRoll component to display the local images
.This local images i need to save to the cloudinary through
node.js.But my CameraRoll asset uri generating like below
var assetURL = "assets-library://asset/asset.JPG?id=B37E1F30-C8F4-4648-8BF2-1B8BD638141D&ext=JPG”;
But the images are not saved in cloudinary through node(it's expecting
base64 format)
here, you can find some information on how to convert Image object to data URI.
See if it helps.