A file upload component.

Parameters:
NameTypeDescription
propsobject

Component props.

Properties
NameTypeDescription
acceptedFileTypesstring

The allowed file types for the input's accept attribute.

allowedFileTypesArray

The allowed file types helper text.

allowMultiUploadboolean

Allow multi-file upload.

aboveDropZoneChildrenJSX.Element

Slot content for React element children rendered above the drop zone.

belowDropZoneChildrenJSX.Element

Slot content for React element children rendered below the drop zone.

clickableboolean

Whether clicking the upload area triggers the file upload UI.

customAttributesobject

Custom attributes for the component.

customClassesstring | Array | object

Custom classes for the component.

customWrapperAttributesobject

Custom attributes for the component wrapper.

customWrapperClassesstring | Array | object

Custom classes for the component wrapper.

disabledboolean

Whether this component should be disabled.

externalManagerboolean

Whether to use the external file manager.

fileArrayArray

The files to be uploaded.

fileIdstring

The ID of the file.

fileURLstring

The url for an already uploaded file.

hasDropboolean

Whether to enable file dropping functionality.

i18nobject

Translated strings for the UI.

idstring

ID of the file input.

imagePreviewboolean

Whether to show an image specific or generic file preview. Only supported for single file uploads.

maxHeightstring | number

The maximum height for the image.

maxWidthstring | number

The maximum width for the image.

multiPreviewActionButtonAttributesobject

Custom attributes for the multi-file preview action button.

multiPreviewActionButtonClassesstring | Array | object

Custom classes for the multi-file preview action button.

namestring

The name attribute for the file input.

onFileSelectfunction

Handler for file selection.

previewAttributesobject

Attributes for the preview.

previewClassesArray

Classes for the preview.

showAllowedFileTypesTextboolean

Whether or not to show the allowed file types helper text.

showAllowedImageDimensionsTextboolean

Whether or not to show the allowed image dimensions helper text.

showMultiPreviewActionsboolean

Whether or not to show the multi-file preview actions.

spacingstring | number | Array | object

The spacing for the component.

themestring

The theme for the component.

uploadIconstring

The icon to show for the upload button.

uploadIconPrefixstring

The prefix to use for the upload button icon.

wrapperAttributesobject

Custom attributes for the wrapper element.

wrapperClassesstring | Array | object

Custom classes for the wrapper element.

refobject | null

Ref to the component.

Since
  • 1.1.15
Returns:

The file upload component.

Type: 
JSX.Element
Example
import FileUpload from '@gravityforms/components/react/admin/elements/FileUpload';

return <FileUpload name="file-upload" />;

Methods

(inner) handleRemove(event) → {void}

Handler for removing file from single-file upload field.

Parameters:
NameTypeDescription
eventobject

Event object.

Since
  • 1.1.15
Returns:
Type: 
void

(inner) handleRemoveMultiFile(event, index) → {void}

Handler for removing file from multi-file upload field.

Parameters:
NameTypeDescription
eventobject

Event object.

indexnumber

Index of the file to remove.

Since
  • 5.8.5
Returns:
Type: 
void

(inner) onFileInputChange(event) → {void}

Handler for change event on file input.

Parameters:
NameTypeDescription
eventobject

Event object.

Since
  • 1.1.15
Returns:
Type: 
void

(inner) onFileInputKeyDown(event) → {void}

Handler for keydown event on file input.

Parameters:
NameTypeDescription
eventobject

Event object.

Since
  • 2.0.1
Returns:
Type: 
void

(inner) onSelectFile(files) → {function}

Handler for selecting a file.

Parameters:
NameTypeDescription
filesArray | FileList

Array of files.

Since
  • 1.1.15
Returns:

Function to clear timeout.

Type: 
function

(inner) onTargetClick(event) → {void}

Handler for click event on file drop target.

Parameters:
NameTypeDescription
eventobject

Event object.

Since
  • 1.1.15
Returns:
Type: 
void

(inner) renderFileOptions() → {string}

Renders allowed file type options.

Since
  • 1.1.15
Returns:

String list of allowed file types.

Type: 
string