VUpload ​

VUpload wraps Element Plus Upload and adds built-in validation, filename sanitization, cover-file handling, and download-oriented preview behavior.

Basic Usage ​

Initialize the component from existing file data, use cover-file with limit="1", and mock a Promise-based http-request handler.

image/*,less than 5MB

Picture Card Download ​

Render seeded images with list-type="picture-card" and turn preview clicks into downloads through preview="download".

  • press delete to remove
  • press delete to remove

Drag Upload ​

Enable drag-and-drop upload with custom drag text, accepted formats, and built-in size/type hints.

Drop report files here or click to upload
.xls / .xlsx / .csv,less than 5MB

Behavior Notes ​

  • model-value is an input prop used to initialize or externally reset the internal file list. The component does not emit update:modelValue; use on-change if you need to sync external state.
  • When before-upload is not provided, VUpload validates accept, size, and max-file-name-length for you. Providing a custom before-upload replaces that built-in validation.
  • Selected filenames are sanitized before upload by removing spaces and special characters from the base name while keeping the extension.
  • After a file leaves the ready state, on-change receives a cloned normalized array shaped like { name, url, fileName, fileUrl }. While a newly selected file is still in ready, it receives the raw UploadFiles list.
  • When cover-file is enabled, files with the same sanitized name replace older entries. If limit is 1, selecting a new file after the limit is reached replaces the current file.
  • preview="download" turns preview clicks into downloads. Use download-method to override the default browser download. Other preview values currently have no built-in behavior in this wrapper.
  • force-update-flie-list follows the current implementation spelling and forces model-value to overwrite an already initialized internal file list.
  • When http-request is provided, it must return a Promise because VUpload chains then, catch, and finally on it.

Value Formats ​

  • model-value accepts an array, a single object, or a string.
  • String values are parsed as a JSON array first. If parsing fails, they are treated as a |-separated list of file URLs and converted to { fileName, fileUrl }.
  • When auto-upload is true, existing records are normalized from fileName / fileUrl to the internal name / url fields used by Upload.
  • When auto-upload is false and model-value is an array, the array is used directly as the internal UploadFiles list.

API ​

VUpload Attributes ​

NameDescriptionTypeDefault
model-valueinitial or external file dataarray / string / object[]
actionupload URLstring'#'
headersrequest headersobject—
methodHTTP methodstring'post'
dataextra request payload passed to Uploadobject / function / Promise{}
nameuploaded file field namestring'file'
multipleallow selecting multiple filesbooleanfalse
dragenable drag and drop modebooleanfalse
with-credentialssend cookies with the requestbooleanfalse
show-file-listwhether to show the upload listbooleantrue
acceptaccepted file typesstring''
auto-uploadstart upload immediately after selectionbooleantrue
list-typefile list display typeenum'text'
http-requestcustom upload function that must return a Promisefunction—
disableddisable upload interactionbooleanfalse
limitmax number of filesnumber—
before-uploadcustom pre-upload hook; overrides built-in validationfunction—
before-removehook before removing a filefunction—
on-changecallback when the file list changesfunction—
on-successcallback after a file uploads successfullyfunction—
on-progresscallback during upload progressfunction—
on-errorcallback after upload failurefunction—
on-exceedcallback when selected files exceed limitfunction—
crossoriginnative crossorigin attribute for upload resourcesenum—
list-inlinedisplay the file list inlinebooleanfalse
cover-filereplace existing entries with the same name; when limit is 1, exceeding the limit replaces the current filebooleanfalse
hide-buttonhide the button trigger after reaching limitbooleanfalse
show-tipshow the built-in format and size tipbooleantrue
sizemax file size in KBnumber5120
size-tipcustom size tip textstring''
format-tipcustom accepted format tip textstring''
format-err-tipcustom message shown when type validation failsstring''
previewpreview click mode; only download has built-in behavior in this wrapperenum''
download-methodcustom download handler used when preview="download"function—
max-file-name-lengthmax allowed file name lengthnumber—
drag-textcustom text shown in drag modestring''
btn-attrsextra props passed to the built-in button triggerobject{}
btn-textcustom button textstring''
force-update-flie-listforce model-value to overwrite an initialized internal file listbooleanfalse

VUpload Events ​

NameDescriptionType
uploadchangeemitted before upload starts and after the custom upload promise settlesfunction

VUpload Slots ​

VUpload does not forward custom slots. The button trigger, drag area, and tip content are rendered internally from props.

Source ​

Docs