Upload And Retrieve Image In Node.js?
I'm new to nodejs. I'm trying to upload an image to the server and store that image path in the localhost's PostgresSQL database as like this (myipaddress:3000/uploads/images/12345
Solution 1:
Follow this (http://www.hacksparrow.com/handle-file-uploads-in-express-node-js.html) to upload an image to server in nodejs.
Once you followed. It will return response like this
File uploaded to: ./public/images/85d15c2f7e812a03faa44bdef0ce41f5.png - 278070 bytes
The response shows that your image is stored in the public/images directory
Image Name : 85d15c2f7e812a03faa44bdef0ce41f5.png
Image Path : ./public/images/85d15c2f7e812a03faa44bdef0ce41f5.png
You can load the image with the server ip by removing the public from the URL. Because we can directly access the content from the public directory without specifying public.
So the following link is enough to load the image from the URL.
your-local-ip:port/images/85d15c2f7e812a03faa44bdef0ce41f5.png
eg:
http://localhost:3000/images/85d15c2f7e812a03faa44bdef0ce41f5.png
Post a Comment for "Upload And Retrieve Image In Node.js?"