Validate File Upload in JavaScript and Reject Photos That Are Not Documents
Filestack filestack.com
Listen to this summary
To validate file upload in JavaScript by what a photo shows, check three things after the upload: whether there is a page in the photo, whether it has text, and whether it is the right document. Two Filestack features do the checking, Document Detection finds the page and OCR reads the words on it, so the form enables its submit button only for the right photo. We built it with a plain , the JavaScript file upload library from a script tag, and a small Node server with no packages.
An expense form that asks for a photo of the receipt also gets holiday photos, blank pages and delivery notes, and finance finds them a week later. Every one of those files is an image of a sensible size, so the usual type and size check passes them all:
More ways to use this
Open on another device
Scan to open this page. Your saved notes and account access are not included.