Discover · filestack.com

Validate File Upload in JavaScript and Reject Photos That Are Not Documents

Filestack filestack.com

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 this QR code to open the same public page

Scan to open this page. Your saved notes and account access are not included.

Download QR code

Open the page link

In the piece

Keep going

Each of these is read from what this estate already kept: the feed a piece came through, the publisher behind it, the credits and topics the publisher printed. None of it is a recommendation, an identity or a record kept anywhere else.

Also from Filestack

  1. Fix ‘The Uploaded File Exceeds the upload_max_filesize Directive in php.ini’carlc filestack.com
  2. Angular Material File Upload With Scan and Read StatesJoshua filestack.com
  3. Best Image Format for Web Pages in 2026Joshua filestack.com
  4. How to Set Up Virus Detection on the New Filestack PortalFavour Onuoha filestack.com
  5. How to Secure File Uploads With Signed Policiescarlc filestack.com
  6. An SFTP Alternative for Partner Uploads With a Signed Link That Scans for Virusescarlc filestack.com