Last active
January 28, 2021 15:44
-
-
Save pokisin/9d8e2149073849e628c795f720dd860d to your computer and use it in GitHub Desktop.
Cannot app.use(multer). “requires middleware function” error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------- SOLVED -------------------------- | |
You need to use app.use(multer({dest:'./uploads/'})) in the form of one of these: | |
app.use(multer({dest:'./uploads/'}).single(...)); | |
app.use(multer({dest:'./uploads/'}).array(...)); | |
app.use(multer({dest:'./uploads/'}).fields(...)); | |
ie: | |
app.use(multer({dest:'./uploads/'}).single('file')); | |
And be sure to have something like: | |
<form action="/file_upload" enctype="multipart/form-data" method="post"> | |
<input type="file" name="file"> | |
<input type="submit" value="Upload file"> | |
</form> | |
In your html. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment