Answer the question
In order to leave comments, you need to log in
File upload express/multi. Does the request work successfully only in POSTMAN?
Hello! Faced such problem when uploading a file to the server. I use express.js along with multer. The essence of the problem is that using POSTMAN the request is executed and the file is successfully sent to the server. But when you do everything simply through the form on the page, the request is executed, but the file is not uploaded to the server. What did I screw up? Any ideas?
multer = require('multer')
upload = multer({ dest: 'uploads/' })
editor.post '/import',upload.single('import'), (req, res) ->
session = req.session
if typeof session.userId == 'undefined'
res.redirect 'http://localhost:' + config.PORT + '/auth'
res.end()
console.log req.body.import
console.log req.file
res.end()
<form method='post' action='/editor/import' enctype='multipart/form-data'>
<input type='file' name="import" />
<button type="submit">Импортировать</button>
</form>
Answer the question
In order to leave comments, you need to log in
In development, I use React.js. The problem was caused by React ignoring the enctype="multipart/form-data" attribute when rendering. The solution to this problem is to change the name of the attribute from ecntype to encType.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question