Skip to main content

FileUpload

shadow

The FileUpload component provides a universal file upload function for web applications. It supports customizable attributes such as allowed file types, part size or also maximum file size, along with drag-and-drop methods and traditional file selection.

Basic usage

The sample represents the basic flow of uploading files without additional modifications. This is a good start for understanding both the structure and the behavior of the component.

With the icon

The preview replaces the thumbnail with an icon, which is especially useful for file types that don't have a meaningful preview image.

When to use

Use wje-file-upload when the user enters a value, selects options, or performs an action on a form.

When not to use

Don't just use it as a visual decorative element without interaction. In this case, give priority to the presentation components.

Accessibility

Always link the component to the description (label/aria-label), keep keyboard control, and display a clear message on validation errors.

  • Keep validation rules and error states consistent across the entire form.
  • For asynchronous operations, display the load status or disabled status.
  • For complex forms, prefer smaller sections and immediate feedback.

Attributes and properties

acceptedTypes

PopisNastavuje textovú hodnotu uloženú vo voľbe accepted-types.
Atribútaccepted-types
Typstring
Predvolené-

autoProcessFiles

PopisUrčuje, či je voľba auto-process-files zapnutá a ovplyvňuje správanie komponentu.
Atribútauto-process-files
Typboolean
Predvolenétrue

chunkSize

PopisNastavuje rozmery alebo veľkosť pre voľbu chunk-size.
Atribútchunk-size
Typnumber
Predvolené-

label

PopisNastavuje zobrazený alebo prístupný textový štítok.
Atribútlabel
Typstring
Predvolené-

maxFileSize

PopisNastavuje rozmery alebo veľkosť pre voľbu max-file-size.
Atribútmax-file-size
Typnumber
Predvolené-

maxFiles

PopisNastavuje číselnú hodnotu používanú vo voľbe max-files.
Atribútmax-files
Typnumber
Predvolené10

noUploadButton

PopisUrčuje, či je voľba no-upload-button zapnutá a ovplyvňuje správanie komponentu.
Atribútno-upload-button
Typboolean
Predvolenéfalse

toChunk

PopisUrčuje, či je voľba to-chunk zapnutá a ovplyvňuje správanie komponentu.
Atribútto-chunk
Typboolean
Predvolenéfalse

uploadUrl

PopisNastavuje odkaz na zdroj pre voľbu upload-url.
Atribútupload-url
Typstring
Predvolené/upload

Events

NázovPopis
wje-file-upload:file-removedVyvolá sa pri odoslaní udalosti wje-file-upload:file-removed.
wje-file-upload:files-selectedVyvolá sa pri zmene výberu.
wje-file-upload:errorVyvolá sa pri chybovom stave komponentu.
wje-file-upload:files-addedVyvolá sa pri odoslaní udalosti wje-file-upload:files-added.
wje-file-upload:files-uploadedVyvolá sa pri odoslaní udalosti wje-file-upload:files-uploaded.
wje-file-upload:startedVyvolá sa pri odoslaní udalosti wje-file-upload:started.
wje-file-upload:file-uploadedVyvolá sa pri odoslaní udalosti wje-file-upload:file-uploaded.

Methods

addFilesToQueue

PopisPridá files to queue do spravovanej kolekcie komponentu.
Signatúra(files: any) => void

uploadFiles

PopisSpustí metódu uploadFiles na vykonanie logiky komponentu a aktualizáciu jeho stavu.
Signatúra() => void

createPreview

PopisVytvorí preview a pripojí ho do štruktúry komponentu.
Signatúra(file: File, reader: FileReader) => HTMLElement

createThumbnail

PopisVytvorí thumbnail a pripojí ho do štruktúry komponentu.
Signatúra(file: File, reader: FileReader) => HTMLElement

assertFilesValid

PopisSpustí metódu assertFilesValid na vykonanie logiky komponentu a aktualizáciu jeho stavu.
Signatúra(file: File) => void

resetFormState

PopisObnoví form state na počiatočné hodnoty.
Signatúra() => void

CSS shadow parts

NázovPopis
nativeŠtýluje koreňovú shadow časť komponentu.
file-listŠtýluje shadow časť file-list.
upload-buttonŠtýluje shadow časť upload-button.

CSS custom variables

Pre tento komponent nie sú dostupné žiadne vlastné CSS vlastnosti.

Slots

NázovPopis
defaultPredvolený slot pre hlavný obsah komponentu.