Ant Design Svelte

Upload / UploadDragger

Select, drag and drop files with a controlled list.

When to use

Upload selects files and shows the upload progress, result and available actions. UploadDragger adds a drag area with the same list and transport contract. Use them for attachments, avatars, and image sets.

Demos process files locally: customRequest simulates sending, and manual script defers it until the button is clicked. For your application, specify a server action or your own request implementation.

CSS prefixes Upload show global ConfigProvider.prefixCls and local prefixCls without resetting state. Trigger, list and Upload/Dragger states follow prefixCls. Button, Progress and Tooltip separately inherit the common prefix. Here is manual mode: file selection does not send a network request.

List and pre-processing

FileList - an UploadFile array with a stable uid, name, state and progress. When controlling externally, accept info.fileList from each onChange. defaultFileList specifies initial entries, such as previously saved attachments.

Problem Setting Example
Select and send files customRequest, onChange Click to download
Manage list and deletion fileList, onRemove Managed List
Set file error text response, error.statusText, error.message, locale.uploadError Initial list
Select folder with attachments directory, accept Folder and attachments
Customize name link UploadFile.linkProps Link attributes
Set defaults to everyone Upload ConfigProvider.upload General settings
Customize action icons showUploadList.*Icon Icons and information
Configure loading bar progress, UploadFile.percent Progress registration
Design parts of the list and trigger classNames, styles Semantic DOM
Change file icon snippet iconRender Your icons
Rearrange files and change line itemRender, fileList Own line and order
Receive files from buffer pastable, beforeUpload Inserting files
Exclude inappropriate file beforeUpload, UPLOAD_LIST_IGNORE PNG only
Change the body before sending Returned Blob Transformation before request
Delay sending beforeUpload={() => false} Manual download start

beforeUpload=false stops automatic uploading, but leaves the file in the list without the required status. A rejected Promise also stops the request. The separately imported constant UPLOAD_LIST_IGNORE eliminates the entry completely. The Blob returned by the handler replaces the body of the request; the source file is saved in the model.

pastable enables pasting files from the buffer for Upload and UploadDragger; default is false. The handler listens to the entire document: focus on an adjacent field does not limit loading. A regular text insert remains native. Each active Upload with pastable receives an event, so on a page with several loaders, enable it only for the one you need. disabled, including ConfigProvider, blocks insertion. When leaving the page, the subscription is removed.

Inserted files go through the same beforeUpload, fileList-driven transport that select and drop do. With multiple paste/drop, filters by accept; in single the first source file is taken before filtering. Check mandatory restrictions separately in beforeUpload. Example starts with insertion disabled, saves files locally and allows you to switch to Dragger or local customRequest without a network.

directory adds directory/webkitdirectory to file input. The dialog selects a folder, drop/paste bypasses the nested FileSystemEntry and saves the relative path to originFileObj.webkitRelativePath. Traversal reads all portions directory reader; unavailable entries are skipped. multiple remains a separate prop and does not limit the traversal to a single file. When disabled or leaving the page, the late reading result is not included in the list.

With directory accept is applied before beforeUpload, including selection by dialog. An object with filter:'native' leaves the checking to the browser; callback filter sets its own check. Support for selecting folders and entries when drop/paste is browser dependent: if entries are not available, crawling does not restore them from regular files. The structure on the server is determined by your transport, not the fileList.

accept specifies the available selection formats; beforeUpload is suitable for checking size and application conditions. multiple allows multiple files, maxCount limits the list; if maxCount=1, the new file replaces the old one. An entry removed from a managed model no longer receives status updates: keep the list up-to-date for late transport responses.

Request, progress and cancellation

Standard sending uses XHR: action specifies the URL, name is the name of the file field, method is the HTTP method. data, headers and withCredentials pass the request parameters. action and data can be calculated asynchronously for a specific file.

customRequest receives file, action, filename, method, data, headers and callbacks onProgress/onSuccess/onError. Report the percentage via onProgress and terminate the request with one of the last two handlers. info.defaultRequest allows you to call the original XHR implementation instead of completely repeating the transport.

Return an object with an abort() method from customRequest. Use it to stop the request and release its resources. When Upload unmounts, it calls this method for each pending upload, even if customRequest closed the form before returning the object.

To cancel an upload from a button, get the Upload instance with bind:this. Call abort(file) for one request or abort() for all active requests. In the basic example, the button also updates the status of the cancelled files in the controlled fileList.

onRemove can return false or a Promise with false to prevent removal; a rejected Promise also saves the record. If deletion is allowed, the active send is cancelled. Guided Example shows delete prohibited separately from disabled.

List view and actions

listType selects text, picture, picture-card or picture-circle. Wall of images and round version use the same model. Url specifies the file link, thumbUrl specifies the thumbnail; previewFile allows you to asynchronously prepare your image.

linkProps sets the attributes of the file name link if there is a url: an HTMLAnchorAttributes object or JSON. Native class, onclick and string style are used. target, rel, title, download, aria-* and data-* can be specified explicitly; href is always taken from file.url. Attributes do not apply to a thumbnail, a separate preview action, or a name without a url.

onclick is called before onPreview. event.preventDefault() cancels preview, return false and stopPropagation() do not. JSON only transfers serializable attributes; an invalid line throws a SyntaxError. In the example, you can disable onPreview and download local text via download.

showUploadList configures the visibility of preview/remove/download and snippet extra. Snippets previewIcon/downloadIcon/removeIcon receive the file and change the contents of regular actions. ShowIcon, names from locale, statuses, disabled and callbacks are preserved. Preview icon is used in card/circle, download - only for done. An empty snippet does not hide the control: to do this, set showIcon; undefined returns standard SVG, 0 is displayed. onPreview and onDownload pass the action to the application: demos open the local Modal or show the file name. Free Object URLs created by the application when replacing or deleting an image and when unmounting.

children sets the Svelte snippet of the Dragger button or content. Pass disabled to the child button too, so that its appearance and accessibility are consistent with Upload. bind:inputElement and bind:nativeElement are available after mount; There are no separate focus/blur.

iconRender - Svelte snippet with file and current listType. It replaces the icon, including the uploading state. An empty snippet leaves space without a fallback; the number 0 is displayed. The finished image thumbnail in picture views remains a priority.

itemRender gets originNode, file, current readonly fileList and actions. originNode is rendered via @render originNode() and includes the standard error Tooltip line. You can supplement it or replace it completely. An empty snippet leaves the outer file container empty; undefined returns the default string.

The UploadItemRenderActions type describes preview(event?), download() and remove(). They call callbacks Upload; remove saves veto onRemove and canceling the request. The passed preview MouseEvent is canceled if onPreview is present; without a callback, the action does not open the viewer automatically. Custom buttons do not inherit the disabled and visibility of actions: set them explicitly. In the download example, it only shows the file name.

The order is determined by the fileList array of the application. The example combines native drag and drop with accessible Above/Below buttons; the stable uid is saved by the note editor. itemRender itself does not sort the data and does not include React dnd-kit.

Progress configures the linear file bar: size, showInfo, colors/gradient, status/success, steps, format, semantic slots and ARIA of an existing Progress. type and percent are not included in the object: the percentage is stored in UploadFile and updated by the transport via onProgress. For thickness use size. The bar appears 300 ms after the mount line, only when uploading and percent is specified; with SSR it doesn’t exist yet.

Without local and general progress, size=[-1,2] and showInfo=false are used. Global and local parameters are combined by field: a local empty object stores provider progress. If there is no general progress, the passed object, including the empty one, replaces defaults Upload; missing fields receive defaults Progress. The available name can be set using the aria-label/aria-labelledby fields of UploadFile; progress props take precedence. If a name is not specified, localized text is stored with the file name.

classNames/styles is styled as root, list, item and trigger. classNames specifies classes, styles – CSS strings; both accept record or callback from { props }. Callback sees listType, type, multiple, hasControlInside, disabled and showUploadList enabled, other input settings remain original. DOM bindings nativeElement/inputElement are not passed to callback. Don't change the state inside the callback.

Root - external wrapper span, list - list container, item - regular line inside the file container, trigger - selection area or Dragger, not hidden input. If itemRender completely replaces originNode, the item slot is not rendered. class and rootClassName complement classNames.root; styles.root is applied to the wrapper and its variables. Regular style refers to trigger and overrides styles.trigger. Progress settings have their own semantic slots.

ConfigProvider.upload specifies class/style, classNames/styles, accept, customRequest and progress for Upload and Dragger. A nested provider without upload inherits record; the transmitted upload replaces it entirely. An empty object clears only the upload-record, not the theme and other settings.

Classes from the general and local design are accumulated. The CSS lines for general slots come before local ones; for trigger the order is: general styles.trigger, general style, local styles.trigger, local style. Local empty classNames/styles do not override global ones. Callback receives the original local accept, not the inherited value. An empty local accept removes the general filter; checking the validity of the file remains a beforeUpload task.

Local customRequest has priority over the general one. Changing the handler affects the following files, the running request and the list are saved. The example holds requests until the button is pressed and shows the cancellation of incomplete ones with unmount; in an area with an empty record beforeUpload returns false so as not to run the standard XHR.

Component Upload design tokens work and are set separately from component config. Supported settings are listed in API.

Refs and file metadata

Lifecycle methods demonstrate UploadRef for Upload and UploadDragger through bind:this. onBatchStart accepts UploadBatchFileInfo[] containing file and parsedFile: null retains the file without uploading. It does not run beforeUpload or a transport. onProgress, onSuccess and onError update a record only while its uid remains in the current list; onSuccess parses a JSON response string.

FileList, upload, nativeElement and inputElement are read from the current ref. UploadUploaderRef provides abort(file?), which cancels a request without removing its row. After unmount, batch preparation neither publishes records nor starts a transport.

In the picture wall, fileName stores optional metadata and the application uses preview as a cache. The row label still uses name; thumbnails use thumbUrl/url. children=undefined hides the selection area at the limit while preserving the hidden input for the next selection.

Examples

logo.webp

The model is updated immediately; the deleted line remains until the end of the animation. Returning the same uid before completion saves the string. The initial files appear without animation; The system motion reduction setting is taken into account.

Adding and deleting rows

Four types of list, returning the same uid and disabling motion. The model list changes immediately, registration is completed separately.

0

Empty thumbUrl saves the image and preview by url, but disables the generation of previewFile. The generator needs originFileObj and thumbUrl === undefined. A non-empty thumbUrl takes precedence.

Preview source

Thumbnail and preview source

Empty thumbUrl uses url without generation; non-empty takes precedence. If undefined and originFileObj is used, previewFile is called.

No files selected

Push to load

Local customRequest shows progress and completion. A name ending in .fail shows an error. Removing or aborting cancels the timers; requests to the server are not fulfilled.

Avatar not selected

Avatar selection

beforeUpload checks PNG/JPEG up to 1 MB. false stops sending, keeping the local preview. Object URL is freed when replaced and unmounted.

readme.txt
draft.txt
archive.zip

Initial file list

defaultFileList specifies the ready states done, uploading and error. Point to archive.zip: error.statusText takes precedence over error.message. beforeUpload=false allows you to add files without automatic upload.

Image preview

Wall of images

Managed picture-card with local thumbnails, deletion and Modal. Preview also works for added files; Object URLs are cleared.

File preview

Round images

listType="picture-circle" changes the shape of the thumbnails. The file selection remains local thanks to beforeUpload=false.

policy.txt
draft.txt

policy.txt, draft.txt

Managed list and deletion veto

fileList belongs to the application. onRemove can reject the removal; the outer Button shows a separate model change.

Click or drag files

The files will remain in the local list.

Drop: 0; files: 0

Drag and drop files

UploadDragger accepts files through file selection and the drop event. onDrop receives event; beforeUpload=false saves files locally.

Select PNG file

List is empty

PNG only

accept limits the selection in the dialog, beforeUpload checks the type. UPLOAD_LIST_IGNORE excludes a rejected file from the list; false keeps valid without sending.

Turn on paste, copy the file or image and press Ctrl+V or ⌘V. The handler acts on the entire document, including when there is focus in the note field below. Plain text continues to be inserted into the field.

Empty No checks No batches No requests Changes: 0 Waiting mount

By default, beforeUpload=false leaves files locally. If you clear this flag, customRequest only confirms the local result, without a network request. Multiple uses accept; in single paste/drop takes the first source file before filtering. Specify file validity check separately in beforeUpload.

Inserting files from the buffer

pastable for Upload and UploadDragger: paste document processing, multiple/accept, beforeUpload, local customRequest and disabled. Insertion is enabled explicitly; files are not sent to the server.

Click or drag a folder with text files

No folder selected No checks Waiting mount

Directory includes folder selection and attachment bypass when dropping. The path is read from originFileObj.webkitRelativePath; The folder structure is not sent to the server automatically. BeforeUpload returns false: the files remain local.

In folder mode, accept filters .txt to beforeUpload. "Trust accept dialog" sets filter:'native' and disables this filtering in the code. Multiple remains a separate prop: directory does not automatically enable it and does not truncate attachments to a single file.

Select folder and attachments

directory in Upload and Dragger, relative paths, multiple and accept. The folder is selected by the native dialog or transferred to the area; beforeUpload leaves the files locally.

PNG
cover.png
TXT
error.txt
TXT
pending.txt

IconRender gets the current file and listType, including the uploading state. An empty snippet does not return the default icon; the number 0 is displayed. The finished image in picture views has priority over the icon.

Initial states are specified for comparison. New files stay local: beforeUpload returns false.

Custom file icons

iconRender as Svelte snippet with file/listType: states, empty result, number 0 and priority of the finished thumbnail in picture views.

Position 1 from 3

Position 2 from 3

Position 3 from 3

alpha.txt, beta.txt, policy.txt No download No deletion

Drag the line or use "Above" and "Below". The order is determined by the application's fileList; a persistent uid preserves the line and its note. OriginNode - snippet of a standard line with Tooltip error.

Actions call callbacks Upload; disabled and the availability of its buttons is determined by the application. Policy.txt is protected via onRemove. Downloading here only shows the name; new files are not sent.

Your line information

Own line and file order

itemRender gets originNode, file, current list and actions. Sorting by drag and drop or buttons saves notes; viewing, downloading and veto deletion are associated with callbacks Upload.

File preview

Pictures in the list

picture shows a thumbnail next to the file name. The initial data and added images use the same list.

Sketch file

General sketch of the text file

Your own file thumbnail

previewFile returns a Promise with the source of the thumbnail. In the example, the text files receive a generic SVG thumbnail; the file is not transferred to the server.

One file

Up to three files

Quantity limit

maxCount=1 replaces the previous file. In multiple, the list is limited to three files.

No text selected yet

Pre-query conversion

beforeUpload returns a Blob with the title before the source text. customRequest reads the converted bytes and validates the local result.

readme.txt· 128 bytes
draft.txt· 64 bytes

Loading not requested

List actions and additional information

showUploadList controls the visibility of actions for each file, extra adds information. The action icons are shown separately in the following example.

No download No deletion map.svg, draft.svg

Snippets receive the current file and change the contents of standard actions. An empty snippet leaves the control with an accessible name; to hide use show*Icon. Preview is shown in card/circle, download - only for done. Disabled blocks deletion, viewing and downloading remain available.

Callbacks here show the file name; draft.svg is protected via onRemove. Undefined returns the default icon, the number 0 is displayed. New files remain locally without being sent.

Upload action details

Action icons and information

Snippets previewIcon/downloadIcon/removeIcon get the file. Visibility, available names and callbacks remain standard; own, empty and standard icons are compared.

General and local settings

sample.txt
sample.txt: uploading Waiting mount

Inherited Dragger

Click or drag the file

sample.txt
sample.txt: uploading Waiting mount

Empty nested record

sample.txt
sample.txt: uploading Waiting mount
No requests Expect: 0 No cancellations

Sample.txt - sample band with 42%. New files are processed locally: Click End Requests. In the reset scope, beforeUpload returns false to avoid running the standard XHR.

An empty upload inherits the entire record; an empty nested record replaces it. The classes are accumulated, local CSS lines are applied after the general ones. Progress is merged across fields: an empty local object stores the overall progress. Changing customRequest affects the following files, current requests continue; hiding Upload cancels incomplete ones.

General settings Upload

ConfigProvider.upload: inheritance, record reset, local styles/accept, progress merge and transport selection. Unfinished requests are saved when changing settings and are canceled when unmounted.

Locked selection

disabled is passed to Upload and the nested Button so that their accessibility and appearance match.

archive.zip
uploading: 42

The percentage and status here are set manually, without a request. In the application, percent is updated from onProgress. The bar appears after the mount line with a delay of 300 ms only when status='uploading' and percent is specified.

Without local and general progress Upload sets size=[-1,2] and showInfo=false. General and local parameters are combined by fields. If there is no common progress, any object replaces defaults Upload; missing fields receive defaults Progress. To change the thickness use size. The name can be set to UploadFile, and progress has priority.

File progress design

Progress as a line settings object: size, color, gradient, steps, format and available name. Percent is stored in UploadFile; the absence of a prop and an empty object give different defaults.

report.txt
draft.txt
report.txt, draft.txt Waiting mount

Root designs a wrapper, list - a list, item - a regular line, trigger - a selection area or Dragger. Class and rootClassName complement classNames.root. CSS styles are applied to the relevant parts; regular style overrides styles.trigger.

Callback receives props with defaults and disabled enabled from the current context. Here it changes the line height when disabled. When completely replacing the originNode via itemRender, the item slot is not displayed. New files are saved locally, without being sent.

Semantic DOM list and selection area

Root/list/item/trigger via classNames and CSS lines styles: object, callback, Dragger and priority of normal style. Files and external editor are saved when changing the design.

No files selected

draft.png

Click or drag the file

The file will remain in the local list.

Component theme Upload

Normal list action color and card size, UploadDragger and theme change during local upload. Requests to the server are not fulfilled.

Click or drag files

Select multiple files and start downloading manually.

The demonstration is performed locally without sending files to the server.

Manual boot start

Original UploadDragger from the review: list, separate launch of local demo download and reset. Files are not sent to the server.

Drag and drop file with prefix
Files: 0
General: suite; local: project-upload

Trigger, list and Upload/Dragger states follow prefixCls. Button, Progress and Tooltip separately inherit the common prefix. Here is manual mode: file selection does not send a network request.

CSS prefixes Upload

Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.

[] native=false; input=false; files=0

The methods update the local list without a transport. onSuccess parses JSON; callbacks for a removed uid are ignored. Abort cancels a request without removing the file.

Upload lifecycle methods

UploadRef for Upload and UploadDragger: batch, progress, a JSON response and an error without network requests.

API

Mapping to 21 Upload live page themes on ant.design. Here are 26 cards with working Svelte examples; missing parameters and individual application integrations are listed explicitly.

Topics covered Upload
ThemeExample or limitation
Upload by clickingLocal transport with progress, error and cancellation.
AvatarPNG/JPEG check and local image.
Default FilesInitial done/uploading/error.
Pictures WallControllable Wall, Miniatures and Modal.
Pictures with picture-circle typeRound thumbnails and preview.
Complete control over file listExternal list and deletion veto.
Drag and Dropdrop and local list.
Pastepaste files from document for Upload and UploadDragger; disabled blocks processing.
Upload directoryFolder selection, drop with attachment bypass, relative paths and accept.
Upload manuallyManual local start from original review.
Upload png file onlyType checking and UPLOAD_LIST_IGNORE.
Pictures with list styleThumbnail next to the name.
Customize preview fileYour own previewFile for text files.
Max CountReplacement of one and limit of several files.
Transform file before requestBlob from beforeUpload is passed to the transport.
Aliyun OSSRequires signing application server and cloud configuration. customRequest is available, cloud integration is not added here.
Custom action icon and extra infoVisibility of actions, extra and snippets removeIcon/downloadIcon/previewIcon.
Drag sorting of uploadListitemRender and managed fileList: native drag and drop and rearrange buttons. React dnd-kit is not used.
Crop image before uploadingTrim editor requires separate integration; not added to the page.
Customize Progress BarLine Progress with size, colors, steps, format and ARIA. Percent belongs to the file.
Custom semantic dom stylingLocal and general classNames/styles for root/list/item/trigger, including callbacks.
Main parameters Upload
PropertyDescriptionTypeDefault
progressLine Progress settings without type/percent. General and local parameters are combined by fields. Without general settings, any passed object, including {}, replaces the entire defaults Upload. size specifies the thickness; colors, format, steps, semantic slots and ARIA are related to Progress. The bar appears 300 ms after the mount line when uploading and the specified percent of the file.UploadListProgressProps{ size: [-1, 2], showInfo: false }
classNamesClasses root/list/item/trigger by object or callback from { props }. General and local classes accumulate. Root complements class and rootClassName; item refers to a regular string inside the file container.UploadSemanticValue<T>—
stylesCSS lines of the same four slots or callback. Local ones are applied after general ones. styles.root styles the wrapper; trigger gets provider styles.trigger, provider style, local styles.trigger, local style in that order. Root variables are inherited by trigger.UploadSemanticValue<T>—
directoryFolder selection and FileSystemEntry bypass when drop/paste. Attachments save webkitRelativePath to originFileObj. multiple remains a separate prop, accept is applied before beforeUpload.booleanfalse
iconRenderThe file icon gets the current listType and status. An empty snippet does not return fallback; the number 0 is displayed. The finished image thumbnail in picture views has priority.Snippet<[UploadFile<T>, NonNullable<UploadProps["listType"]>]>Standard icon
itemRenderYour own line instead of originNode or around it. originNode - snippet with error Tooltip; actions contains preview/download/remove. The order of the fileList is set by the application, the disabled of its controls is also set explicitly.Snippet<[Snippet, UploadFile<T>, readonly UploadFile<T>[], UploadItemRenderActions]>Standard line
pastableListen to paste files throughout ownerDocument. Text without files is not intercepted. multiple counts accept; single takes the first source file. Local/inherited disabled blocks insertion; UploadDragger inherits prop.booleanfalse
prefixClsFull CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately.stringConfigProvider.prefixCls + "-upload"
fileListManaged list. Take info.fileList from onChange; bind:fileList is not supported.readonly UploadFile<T>[]Local list
defaultFileListInitial list if there is no fileList.readonly UploadFile<T>[][]
actionAddress of this shipment. On this page the transport is local.string | (file) => string | PromiseLike<string>Empty string
nameMultipart request field name. method supports POST, PUT and PATCH.stringfile
dataAdditional request fields; headers and withCredentials configure the HTTP transport.object | (file) => object | PromiseLike<object>{}
beforeUploadfalse or rejected Promise stops sending, keeping the file in the list. UPLOAD_LIST_IGNORE excludes it; Blob/File replaces the request content.(file, batch) => void | boolean | string | Blob | PromiseLike<...>—
customRequestLocal handler takes precedence over ConfigProvider.upload.customRequest. The change applies to the following files; the current request is saved. The transport receives onProgress, onSuccess, onError and abort. defaultRequest allows you to use the original XHR implementation.(options, { defaultRequest }) => UploadRequest | voidXHR
onChangeCurrent file, list and progress information. If beforeUpload=false the file may not have status.(info: UploadChangeParam<T>) => void—
onRemovefalse disables deletion. Allowed deletion cancels an active file request.(file) => void | boolean | PromiseLike<void | boolean>Allowed
acceptLocal accept, including empty line, overrides ConfigProvider.upload.accept. Types for dialogue and filtering directory or multiple drop/paste. Filter:native disables checking in the code, callback sets its own filter. Perform application validation in beforeUpload.string | { format, filter }Empty string
multipleSelect multiple files at once. directory preserves the prop and does not truncate the folder traversal based on this flag.booleanfalse
maxCountList limit; 1 replaces the previous file.numberNo limit
listTypeList and thumbnail view.text | picture | picture-card | picture-circletext
showUploadListVisibility of the list and actions, extra and snippets previewIcon/downloadIcon/removeIcon with the current file. Snippet changes the content of the control, not the predicate, name or callback. Empty does not hide control; undefined returns the default SVG.boolean | UploadListOptions<T>true
previewFileReturns the source of the thumbnail when originFileObj and thumbUrl === undefined. An empty thumbUrl disables generation and uses the url. isImageUrl determines the display of the image.(file: File | Blob) => PromiseLike<string>Image preview
onPreviewYour preview; Image cards use Modal.(file) => voidGo to URL
onDownloadThe application controls the download. The extra card only shows the received name.(file) => voidOpen URL
onDropDrag event in UploadDragger/type=drag.(event: DragEvent) => void—
disabledBlocks selection, paste and drop processing, including the late result of folder traversal. Pass disabled to your children and controls from itemRender.booleanFrom Form/ConfigProvider
openFileDialogOnClickAllows click to open selection. hasControlInside=false enables role=button and the container's keyboard.booleantrue
localeLabels of loading, deleting, downloading, viewing and errors.UploadLocaleFrom ConfigProvider.locale
inputElementbind:inputElement returns hidden file input; bind:nativeElement - root span.HTMLInputElement—

General settings Upload

UploadConfig sets in ConfigProvider.upload class/style, classNames/styles, accept, customRequest and progress. A missing nested record inherits the parent one, the passed object replaces it entirely. An empty object removes the entire upload-record, preserving other provider settings.

General and local classes are accumulated. For root/list/item, the general slots CSS lines come before the local ones; for trigger the order is: general styles.trigger, general style, local styles.trigger, local style. Local empty classNames/styles do not remove common ones. accept, including the empty string, and customRequest are fetched locally or from provider. Callback semantic slots receives the original local accept, not its inherited value.

Progress is merged on top of a common object by fields. The customRequest change applies to the following files; the running transport is saved. Example uses shared and local transport without a server, inherited Dragger and an empty nested record.

Standard action icons

UploadListOptions<T> accepts previewIcon, downloadIcon and removeIcon how Snippet<[UploadFile<T>]>. They replace the contents of controls; available names from locale, show*Icon, status/disabled and callbacks are preserved. Preview icon is used in picture-card/picture-circle, download - only when done. An empty snippet does not hide the control, undefined returns the standard icon, 0 is displayed.

Progress and semantic types

UploadListProgressProps sets linear Progress settings: size, showInfo, strokeColor, railColor, status/success, steps, format, semantic slots and ARIA. Percent belongs to the file. Without local and global progress, size=[-1,2] and showInfo=false are used. General and local parameters are combined by fields; local empty object does not clear provider progress. If there is no general progress, the passed object replaces the entire defaults Upload. Fields UploadFile['aria-label'] and ['aria-labelledby'] set the name of the band; progress props of the same name take precedence.

UploadSemanticSlots - partial record root/list/item/trigger with string values. UploadSemanticValue<T> accepts record or callback, returning record or undefined. UploadSemanticInfo<T> contains props with listType, type, multiple, hasControlInside, disabled and showUploadList enabled; other input settings, including local prefixCls, remain original; DOM bindings nativeElement/inputElement are excluded. The Callback should evaluate the decoration without changing the state.

Snippets lines and icons

iconRender(file, listType) replaces the file icon. itemRender(originNode, file, fileList, actions) replaces the line or supplements it: output the standard part via @render originNode(). originNode saves Tooltip errors, fileList contains current order.

Export UploadItemRenderActions describes download: () => void, preview: (event?: MouseEvent) => void and remove: () => void. Preview transfers the file to onPreview; when the event is transmitted and onPreview cancels the transition. Without onPreview he does not create his viewer. download calls onDownload or opens URL; remove goes through onRemove, including veto, and cancels the request if deletion is allowed. The visibility of disabled's own buttons is determined by the application.

Name link attributes

UploadFile.linkProps accepts HTMLAnchorAttributes | string: object of native Svelte attributes or their JSON. The default is target="_blank", rel="noopener noreferrer" and title=file.name; linkProps can override them. href is always taken from file.url. Attributes apply only to the name link with a url, not to the thumbnail, preview action or name button without a url.

Use native class, onclick and string style. onclick is called first; preventDefault skips onPreview. Return false and stopPropagation by themselves do not cancel preview. JSON does not pass the onclick function; an invalid line causes a SyntaxError. Example shows updating attributes and downloading local text without onPreview.

UploadDragger and file data

UploadDragger is a separate export with the same props and height for the drop area. It sets type="drag" and hasControlInside=false. UploadRcFile extends File with uid; UploadFile stores name, status, percent, originFileObj, response, error, url, thumbUrl, fileName, preview and linkProps. fileName is optional metadata; the label uses name. Preview is an application cache; thumbnails use thumbUrl/url. Read directory paths from originFileObj.webkitRelativePath; UploadFile has no separate path.

UploadFile.error accepts Error | ProgressEvent | { statusText?: string; message?: string }. When status="error" the Tooltip selects a non-empty string response, then error.statusText, error.message and locale.uploadError. Empty fields are ignored and the response object does not replace the message. Initial list shows the priority of statusText over message.

Full types are in the package. The new onFocus/onBlur from React 6.7.0 are not carried over; For native Svelte events, use the available HTML handlers. directory, pastable, iconRender and itemRender are supported by Upload and UploadDragger. ConfigProvider.upload specifies general Upload and UploadDragger settings; progress and semantic slots are supported locally and via provider.

Methods

UploadRef describes bind:this for Upload and UploadDragger: onBatchStart, onProgress, onSuccess, onError, fileList, upload, nativeElement and inputElement. UploadBatchFileInfo contains file and parsedFile; null leaves the record without uploading. Batch does not run beforeUpload or a transport.

onSuccess parses a JSON string; progress/success/error ignore removed uids. UploadUploaderRef.abort cancels a request without removing its row. After unmount, batch preparation neither publishes files nor starts a transport.

Upload and UploadDragger provide abort(file?) through bind:this - stopping all requests or one UploadFile/uid. The method does not change fileList by itself: basic example separately transfers canceled entries to error.

When Upload unmounts, it calls abort() on each pending request. Use bind:inputElement and bind:nativeElement to access the DOM. Upload has no separate focus() or blur() methods.

DOM and accessibility

The root span contains a hidden input type="file", trigger and a list. When hasControlInside=true, the action is performed by the nested native Button; disabled is passed to both components. UploadDragger makes the area a button with Enter and Space handling.

List actions have accessible names from locale. onPreview allows you to show a Modal instead of following a link. Thumbnails and previews in cards have an alt, and generated Object URLs are freed when replaced, deleted, or unmounted.

classNames/styles are designed in four parts. class and rootClassName add wrapper classes; regular style refers to trigger and takes precedence over styles.trigger. For trigger content, use children. extra complements the standard line, showUploadList controls the visibility of its actions. iconRender changes the icon, itemRender changes the contents of the line inside the file container. Keep accessible names and disabled names for your actions; Provide a keyboard-based alternative to drag-and-drop for sorting.

Upload and UploadDragger parts
SlotElementPurpose
rootExternal span wrapperDesign of the entire area, including CSS variables for descendants.
listList DivVisible when showUploadList; in picture-card/picture-circle also contains trigger.
itemStandard file lineInside list-item-container, including the error Tooltip line. When itemRender is applied only if the originNode is rendered.
triggerSelection Area or DraggerExternal control, not hidden input. Regular style overrides styles.trigger.

Registration tokens

theme.components.Upload sets actionsColor for regular list actions and pictureCardSize for picture-card/picture-circle. The settings also apply to UploadDragger. Actions on top of the image remain white. Updating the theme saves the list and current download. ConfigProvider.upload sets props/defaults separately from theme.components.Upload.

Component tokens Upload
TokenPurpose
actionsColorNormal list action color; actions on top of picture-card/picture-circle remain white.
pictureCardSizeSquare or round card size.

Common tokens of the current topic

Values ​​are read through theme.useToken() and react to section settings.

Common Tokens Upload
TokenCurrent value
colorBgMaskrgba(0,0,0,0.45)
colorBorder#d9d9d9
colorError#ff4d4f
colorFillAlterrgba(0,0,0,0.02)
colorIconrgba(0,0,0,0.45)
colorPrimary#2f54eb
colorPrimaryBorder#adc6ff
colorPrimaryHover#597ef7
colorTextrgba(0,0,0,0.88)
colorTextDescriptionrgba(0,0,0,0.45)
colorTextDisabledrgba(0,0,0,0.25)
colorTextHeadingrgba(0,0,0,0.88)
colorTextLightSolid#fff
borderRadiusLG8
borderRadiusSM4
controlItemBgHoverrgba(0,0,0,0.04)
fontFamily-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSize14
fontSizeHeading230
fontSizeHeading324
fontSizeLG16
lineHeight1.5714285714285714
lineTypesolid
lineWidth1
lineWidthFocus3
margin16
marginXL32
marginXS8
marginXXS4
motionDurationMid0.2s
motionDurationSlow0.3s
motionEaseInOutcubic-bezier(0.645, 0.045, 0.355, 1)
motionEaseInOutCirccubic-bezier(0.78, 0.14, 0.15, 0.86)
padding16
paddingSM12
paddingXS8

FAQ

What is the difference between false and UPLOAD_LIST_IGNORE?

false cancels automatic sending, keeping the file in the list. UPLOAD_LIST_IGNORE excludes the entry completely; the constant is imported separately from @woodger/antd.

Why is the managed list not updating?

Accept info.fileList in onChange. Once you remove an entry from a managed list, do not return it from your transport's late response.

Where does the file error text come from?

When status='error' the standard Tooltip selects the first non-empty line: response, error.statusText, error.message, then locale.uploadError. Blank lines are skipped; the response object is not parsed as a message. UploadFile.error accepts Error, ProgressEvent or an object with string statusText/message. In initial list archive.zip has both fields set: Tooltip shows statusText.

How to download a file or show an image?

Fill in url and thumbUrl or process onDownload/onPreview. In the demos, actions are performed locally.

How to get the source file?

Read originFileObj. With beforeUpload=false, the callback can pass the original File directly; this is reflected in the public type UploadChangeParam.

Where is the server configured?

In action for standard XHR or in customRequest for your own transport. Selecting a file and displaying a list does not in itself create a server handler.

Why can I select an individual file instead of a folder in Safari?

directory and webkitdirectory set the intent for the browser, but do not guarantee the same dialog on all platforms. Limit the selection via accept.format and set accept.filter separately if necessary. Check the size and other application conditions in beforeUpload.

Why did the error or buttons disappear after replacing the line?

When completely replacing originNode, you are responsible for their output. Outputting originNode via @render preserves the default string and Tooltip; the passed actions allow you to link your controls to callbacks Upload. Pass these controls disabled and available names.

Why did progress={} change the height and show the percentage?

Without general progress, this is an explicit replacement for defaults Upload. If there is a provider progress, an empty local object stores its parameters. To get a thin strip without a signature, set size=[-1,2] and showInfo=false explicitly.

Why isn't styles.item styling my string?

Slot refers to the standard line. When itemRender outputs the originNode or style your markup inside the snippet. For an external area use root, for a list use list.

How are the thumbnail and preview source selected?

Example of sources shows the priority of a non-empty thumbUrl over a url. An empty thumbUrl uses the url and disables previewFile. Generation is called only when thumbUrl === undefined and originFileObj is present. Updating a reactive counter inside previewFile does not regenerate the thumbnail for the same file.

When does a deleted row disappear?

List Animations does not delay fileList updates, callbacks, or request cancellations. The line remains until the CSS animation completes or the 2000ms wait limit. Returning the same uid before leaving completes preserves the DOM. The initial files are not animated; theme.token.motion=false and prefers-reduced-motion complete the transition immediately. The picture-card/picture-circle trigger supports enter/leave, preserves its input and does not animate on initial appearance. Progress appearance animation is not available yet.