Upload Button
A button that uploads a single file.
Demo
Installation
Usage
The <UploadButton />
should be used inside a client component.
If your upload route handler is not located at /api/upload
, modify the api
prop to match your path.
The button will open a file picker dialog when clicked, and upload the selected file to the desired route.
Props
Prop | Type | Default |
---|---|---|
api? | string | /api/upload |
route? | string | - |
accept? | string | undefined | - |
metadata? | Record<string, unknown> | undefined | - |
onBeforeUpload? | function | undefined | - |
onUploadBegin? | function | undefined | - |
onUploadProgress? | function | undefined | - |
onUploadComplete? | function | undefined | - |
onUploadError? | function | undefined | - |
onUploadSettled? | function | undefined | - |