File Upload

File Upload Component

Contributed by Chaoyang Li

File upload component allow users to choose local files and upload them to server.

Basic Component

The input tag with 'file' type can be used to create a file upload.

Code Usage

Variants

With icons

You can change the default style and add an icon to the file upload by using label tag.

Code Usage

With multiple file

If you want user uploading multiple file, the multiple attribute can be used.

Code Usage

With limitation

You can limit the format of the uploading file by using the accept attribute of input tag.

Code Usage

You can also limit the size of the loading file.

Code Usage

With preview

Preview only supports image uploading, users can preview their uploaded images before submitting.

Code Usage

Usability

Always show the limitation to the users

If you set any limitation to the uploading file, Using help text to emphasize those limitation.

Add preview if you can

It is very help for user to let them seeing what they uploaded. The preview of the uploaded file can effectively reduce the upload of incorrect files.

Don't set restrictions too strict

Not every users have basic knowledge of the IT world, too strict restrictions can wearing down users' patience. For example, if you set the maximum size of the image are 0.5MB, it is very hard for user to find such small image with the help of compression tool. If the users doesn't know how to use an image compression tool, or doesn't even know the existence of this kind of tool, they probably will never complete the upload.

Accessibility

The input tag supports keyboard operation.

KeyInteraction
SpaceSelects the input and open the file choosing window.
Up, Down, Left and Right ArrowMoves focus to files in the file choosing window.
EnterChooses the file that you selected in the file choosing window and close the window.
EscCloses the file choosing window.

The accessibility of this component can also be improved by other component, like Alert. You can add warning sound with Alert, once user doesn't match the requirement of the file.

Attributes

In addition to the common attributes shared by all input elements, inputs with type file also support the following attributes.

AttributeDescriptionValue
acceptThe accept attribute value is a string that defines the file types the file input should accept.String
captureThe capture attribute value is a string that specifies which camera to use for capture of image or video data, if the accept attribute indicates that the input should be of one of those types.user / environment
multipleWhen the multiple Boolean attribute is specified, the file input allows the user to select more than one file.Boolean

Vision

VersionEditorAuthorDateDescription
v1.0Chaoyang LiChaoyang Li28/09/2023Initial version