1

I have an application in node.js that needs to upload pictures. I have a route that renders the following view:

form(id="image-form", method="post", enctype="multipart/form-data") fieldset label(for="image") Image to Upload: input(type="file", id="image") input(class="btn btn-primary", name="submit", type="submit", value="Submit") 

And, then, in my post route, I simply log the req.files object:

console.log(req.files); 

Which returns an empty object:

{} 

I've double checked that I'm using

app.use(express.bodyParser()); 

per similar questions.

0

1 Answer 1

4

You'll have to set the name of the <input> as well:

input(type="file", id="image", name="image") 

Without that, the <form> is skipping over it when submitting.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.