A file upload component.

Parameters:
NameTypeDescription
propsobject

Component props.

Properties
NameTypeDescription
allowedFileTypesArray

The allowed file types.

customAttributesobject

Custom attributes for the component.

customClassesstring | Array | object

Custom classes for the component.

disabledboolean

Whether this component should be disabled.

fileURLstring

The url for an already uploaded file.

i18nobject

Translated strings for the UI.

idstring

ID of the file input.

maxHeightstring | number

The maximum height for the image.

maxWidthstring | number

The maximum width for the image.

namestring

The name attribute for the file input.

previewAttributesobject

Attributes for the preview.

previewClassesArray

Classes for the preview.

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() → {void}

Handler for removing file from file upload field.

Since
  • 1.1.15
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

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