Skip to content
W WRNexusJS
core component

file-upload

Reusable file-upload component.

@wrnexus/ui 0.2.677 props0 slots0 events

Usage

Components are auto-discovered. Use the component directly in any .wrn view:

<file-upload
  store="public"
  endpoint="/api/upload"
  accept="accept"
  multiple="false"
  max="0"
/>

Legacy mount name: data-component="file-upload".

Props and attributes

PropTypeRequirementDefault
storestringOptional"public"
endpointstringOptional"/api/upload"
acceptstringOptional""
multiplebooleanOptionalfalse
maxnumberOptional0
labelstringOptional"Drag files here or click to browse"
classstringOptional""

Slots

This component does not declare a slot.

Events

This component does not declare a custom event.

Source contract

Installed source: components/file-upload.wrn

// Drag-and-drop file uploader with per-file progress. Progressive enhancement:
// the markup is inert until /__wrnexus/uploader.js loads (auto-injected when a
// page contains `data-uploader`). Pairs with `handleUpload` on the server —
// files POST to `endpoint`, which returns `{ ok, files:[{ key, url, … }] }`.
//
//   <div data-component="file-upload" store="public" endpoint="/api/upload"
//        accept="image/*" max="10000000" multiple="true">
        </div>
component FileUpload {
  props {
    store = "public"
    endpoint = "/api/upload"
    accept = ""
    multiple = false
    max = 0
    label = "Drag files here or click to browse"
    class = ""
  }
  view {
        <div class="wire-fileupload {class}" data-uploader="{store}" data-endpoint="{endpoint}" data-accept="{accept}" data-multiple="{multiple}" data-max="{max}" data-label="{label}">
        </div>
    }
}