X Enterprises
nuxt-x-app-formkit

File Upload

Drag-and-drop file upload component with validation and optional async upload handler.

File Upload

XFormFileUpload is a drag-and-drop file upload zone. It emits selected files as a File or File[] via v-model and optionally calls an async uploadHandler immediately after files are selected.

Components

<XFormFileUpload />

<!-- Single file -->
<XFormFileUpload
  v-model="file"
  accept="image/*"
  accept-label="PNG, JPG, GIF up to 5 MB"
  :max-size="5 * 1024 * 1024"
  @error="toast.add({ title: $event, color: 'error' })"
/>

<!-- Multiple files with upload handler -->
<XFormFileUpload
  v-model="files"
  multiple
  accept=".pdf,.docx"
  :max-files="5"
  :upload-handler="uploadToS3"
/>

Props

PropTypeDefaultDescription
modelValueFile | File[] | nullnullSelected file(s) (v-model)
multiplebooleanfalseAllow multiple file selection
acceptstring"*"Native accept attribute passed to <input type="file">
acceptLabelstring""Human-readable label shown beneath the upload icon (falls back to accept value)
maxSizenumberMaximum file size in bytes; emits @error if exceeded
maxFilesnumberMaximum number of files when multiple is true
disabledbooleanfalseDisable all interactions
dropzonebooleantrueEnable drag-and-drop
uploadHandler(files: File[]) => Promise<void>Called automatically after files are selected; shows uploading spinner

Emits

EventPayloadDescription
update:modelValueFile | File[] | nullv-model sync
errorstringValidation error message (size exceeded, too many files, upload failure)

Exposed Methods

MethodDescription
clear()Remove all selected files
openFilePicker()Programmatically open the OS file picker

AI Context

component: XFormFileUpload
package: "@xenterprises/nuxt-x-app-formkit"
use-when: File upload zones with drag-and-drop, size/count validation, and optional auto-upload
v-model: File | File[] | null
notes:
  - uploadHandler receives File[] and shows a spinner while running
  - @error emits validation messages for size, count, and upload failures
Copyright © 2026