-
-
Save fatiiates/1d5771cc0233e68f533e5b0ca5317f6f to your computer and use it in GitHub Desktop.
Simple Nextjs File Upload — Backend API
This file contains 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
// Backend | |
import formidable from 'formidable'; | |
export const config = { | |
api: { | |
bodyParser: false, | |
}, | |
}; | |
export default async (req, res) => { | |
const form = new formidable.IncomingForm(); | |
form.uploadDir = "./"; | |
form.keepExtensions = true; | |
form.parse(req, (err, fields, files) => { | |
console.log(err, fields, files); | |
}); | |
}; | |
// For the frontend use: | |
// https://gist.github.com/AshikNesin/e44b1950f6a24cfcd85330ffc1713513 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment