Skip to content

DragUpload

DragUpload drag and drop upload component. Its props are the same as FilesUpload, and they can be used together.

Basic Usage

Custom File Hover Style

Props

PropertyDescriptionTypeDefault
v-modelFile list binding valueFilesUploadItem[][]
multipleWhether to support multiple file selectionbooleanfalse
acceptAccepted upload file types, e.g., ['.jpg', '.png', '.pdf']string[][]
max-file-lengthMaximum number of files to uploadnumber10
file-size-limitSingle file size limit in MBnumber5
disabledWhether disabledbooleanfalse

Events

Event NameDescriptionType
upload-beforeHook before upload, can be used to filter or process files(fileList: File[]) => Promise<File[]> | File[]
uploadCustom upload function(fileUploadItems: FilesUploadItem[]) => Promise<any>
update:modelValueTriggered when file list changes(fileList: FilesUploadItem[]) => void
error-messageTriggered on upload error(params: FilesUploadErrorParams) => void

Slots

Slot NameDescription
defaultCustom upload trigger area content
mark-contentCustom style slot for dragging files to drop area

Type Definitions

Can be imported directly

typescript
import {
  FilesUploadItem,
  FilesUploadErrorParams,
  FilesUploadErrorType,
} from 'element-ai-vue'

FilesUploadItem

typescript
interface FilesUploadItem {
  elementFile?: File // Original File object
  fileSize?: number // File size (bytes)
  fileId: string // File unique identifier
  fileName: string // File name
  fileUrl: string // File URL
  fileExt: string // File extension
  uploadingStatus: 'progress' | 'success' | 'error' // Upload status
  progress?: number // Upload progress (0-100)
}

FilesUploadErrorParams

typescript
type FilesUploadErrorParams = {
  type: FilesUploadErrorType // Error type
  message: string // Error message
}

FilesUploadErrorType

typescript
type FilesUploadErrorType =
  | 'EXCEED_MAX_FILE_LENGTH' // Exceeded maximum file count
  | 'EXCEED_FILE_SIZE_LIMIT' // Exceeded file size limit
  | 'INVALID_FILE_TYPE' // Invalid file type