codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

Member-only story

Top 5 Useful HTML File Upload Tips

Mehdi Aoussiad
codeburst
Published in
3 min readOct 28, 2020

--

Image Created By Mehdi Aoussiad.

Introduction

Uploading files across various platforms is a common daily task in 2020. Whether it’s sharing photos on social media or a resume to a job website, it’s hard to imagine life without this functionality. HTML is integral to this process as it provides native file upload support with some assistance from JavaScript.

This article will explore five different usages of the HTML file upload support. I hope you find it useful.

File Upload.
Photo by Ilya Pavlov on Unsplash

1. Simple file upload

In order to use the file uploader functionality, we will need to specify the input type as file. Have a look at the example below:

An input file type allows users with a button to upload one or more files. Upon successful upload, the file API makes it easier to read the file object using JavaScript. To read the file object, we will need to select the input in JavaScript then listen to the change event of the file uploader. Have a look at the example below:

Observe the output in the browser console. Note that the fileList array with the file object has all the metadata information about the uploaded file.

The file object.
The file object in the console.

Here is the CodePen for you with the same example.

--

--

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Written by Mehdi Aoussiad

I focus on writing useful/valuable articles for my audience(Web dev/SEO).

Write a response