Input File

An input field for selecting files to upload using an Upload Files button or a drag-and-drop zone. This field accepts files up to 3.5 MB.

To retrieve the list of selected files, use event.target.files in the onchange event handler. Your selected files are returned in a FileList object, each specified as a File object with the size and type attributes.

<template>
    <lightning-input
        type="file"
        label="Attachment"
        accept="image/png, .zip"
        onchange={handleFilesChange}
        multiple
    >
    </lightning-input>
</template>

lightning-input type="file" handles file selection only. Implement your own file uploading. For example, wire up your component to an Apex controller that handles file uploads. Alternatively, use the lightning-file-upload component for an integrated way to upload files to records.

Last updated

Was this helpful?