Home
← All questions

How to upload and download a file in the browser? in JavaScript

MediumPremiumJavaScript

JavaScript interview practice: Upload a file via fetch/FormData and trigger a client-side download.

Answer

Upload uses an <input type="file">, reads the File, and sends it with FormData over fetch. Download creates a Blob URL and clicks a temporary anchor.

Premium question

Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.

Unlock with Premium