How to Validate File Type When Uploading Files to Express Apps

John Au-Yeung
Nov 2 · 13 min read

File upload is a common operation that are done by users. Therefore, developers have stepped by to develop solutions to make this easy. In Node.js, with the Express web framework and the Multer library, adding file upload feature to your app is easier than ever. It’s easy to validate file type in the uploaded file since the MIME type string of the file is readily available in the parameters of the fileFilter hook as you can see below.

To add file upload feature to your app, first you need a input field with type file . By…

Keep the story going. Sign up for an extra free read.

You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story.
Already have an account? Sign in

John Au-Yeung

Written by

Web developer. Subscribe to my email list now at http://jauyeung.net/subscribe/ . Follow me on Twitter at https://twitter.com/AuMayeung

JavaScript in Plain English

Learn the web's most important programming language.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade