File
The file field can be used to accept files by browsing the file system, or simply by dragging and dropping a file onto the field. It can also be used to output a file for the user to download.
Example
({
type: "file",
accept: "image/*",
label: "File",
})
Options
Input
Use these options when using the field with take
.
accept? | The type of files the field will accept. |
read? | The method used to read the data from the file, or render the data out to a file. The FileReader API is used, and these options map to readAsText , readAsDataURL and readAsArrayBuffer . |
key? | A key to access the value. If provided, each field must have a unique key. See make for more information about accessing values. |
label? | A label describing the purpose of the field. |
detail? | Additional information about the field, disclosed in a tooltip. |
Output
Use these options when using the field with make
.
value? | The content of the file for the user to download. If the value is a string, mimetype is required. |
filename? | The name of the file to use if the user downloads the file. |
mimetype? | The MIME type of the file. If the output value is a string, a MIME type is required. See common MIME types for more information. |
label? | A label describing the purpose of the field. |
detail? | Additional information about the field, disclosed in a tooltip. |
Data
This input returns data in the specified format by read
, or undefined
if no selection has been made. If the user selects a file that does not match the accepted types, it is still read and passed to make
.