0 votes
in HTML by
what you do with the File API in html?

1 Answer

0 votes
by

you can do things like performing client-side file operations:

You can restrict the upload size as you can decipher the file size information. So, if you wish to restrict the user from trying to upload a 40GB file, you can do that.

You can curb the types of files that can be uploaded to a server. So if your service crypt is anticipating to find text files or image files only or any combination, your local client side script code can prevent certain file types from being uploaded.

You can create thumbnail versions of images that are about to be uploaded as you can read image contents either as a binary or geturl and create thumbnails. We can reveal this to the user and explain to them what is going to be uploaded.

You can restrict to check if the modification date of a local file is after or before a particular date. So, you can verify the date of a file and view if it's old or recent.

You can also parse the file contents locally to get complete details. e.g., if you are operating with files over particular type in the images, media files or PDF files. You can look at the file and figure out how big it is, how long the movie is, that kind of thing.

You can modify the file contents before they are sent off to the server. So for example, if someone selects a text file and you read the contents, you can do things like - spell checking, spell correction before the content is sent off.

So, we'll see examples of several of these kinds of scenarios as we move throughout the course.

For now, let's have a look at the FileReader API spec. So, this is the specification for the File API, and you can see this on the W3C portal. October 20th is the newest version of this recording. However, this is a work in progress, and it is regularly updated.

Scroll down to see the different interfaces included in the specification. If you are in search of canonical W3C approved information about the latest version of the file specification, here's where you can go - www.w3.org/TR/FileAPI/.

...