0

I am trying to upload an image to my server through a node.js server using express. I am in the process of writing an CRUD API but I am stuck on how to POST and save the image in a directory on my server.

//post
app.post('/public/media', function(req,res){

});

This is the barebones of my post method. I am trying to store the image in my media file. How should I go about this?

Note, I am not trying to store the image into a database. Rather, I am trying to store the image in a folder on my server and simply store the path to the image in my database.

1 Answer 1

1

Without duplicating an entire article about this issue, checkout this tutorial out. You will need to make slight adjustments to this code if using Express 4, otherwise it will work great.

Comment if you have issues below.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.