FileUpload

FileUpload is an advanced uploader with dragdrop support, multi file uploads, auto uploading, progress tracking and validations.


import { FileUpload } from 'primereact/fileupload';
         

FileUpload basic mode provides a simpler UI as an alternative to advanced mode.

Choose

<Toast ref={toast}></Toast>
<FileUpload mode="basic" name="demo[]" url="/api/upload" accept="image/*" maxFileSize={1000000} onUpload={onBasicUpload} />
         

FileUpload basic mode provides a simpler UI as an alternative to advanced mode.

Browse

<Toast ref={toast}></Toast>
<FileUpload mode="basic" name="demo[]" url="/api/upload" accept="image/*" maxFileSize={1000000} onUpload={onBasicUploadAuto} auto chooseLabel="Browse" />

         

FileUpload is an advanced uploader with dragdrop support, multi file uploads, auto uploading, progress tracking and validations.

Choose

Drag and drop files to here to upload.


<Toast ref={toast}></Toast>
<FileUpload name="demo[]" url="/api/upload" onUpload={onUpload} multiple accept="image/*" maxFileSize={1000000} emptyTemplate={<p className="m-0">Drag and drop files to here to upload.</p>} />
         

Used to create custom item elements in the container.

 
Drag and Drop Image Here

<Toast ref={toast}></Toast>

<Tooltip target=".custom-choose-btn" content="Choose" position="bottom" />
<Tooltip target=".custom-upload-btn" content="Upload" position="bottom" />
<Tooltip target=".custom-cancel-btn" content="Clear" position="bottom" />

<FileUpload ref={fileUploadRef} name="demo[]" url="/api/upload" multiple accept="image/*" maxFileSize={1000000}
onUpload={onTemplateUpload} onSelect={onTemplateSelect} onError={onTemplateClear} onClear={onTemplateClear}
headerTemplate={headerTemplate} itemTemplate={itemTemplate} emptyTemplate={emptyTemplate}
chooseOptions={chooseOptions} uploadOptions={uploadOptions} cancelOptions={cancelOptions} />

         

Uploading implementation can be overriden by enabling customUpload property and defining a custom upload handler event.

Choose

<FileUpload mode="basic" name="demo[]" url="/api/upload" accept="image/*" customUpload uploadHandler={customBase64Uploader} />
         

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-fileuploadContainer element.
p-fileupload-buttonbarHeader containing the buttons.
p-fileupload-contentContent section.
Visit the API documentation for detailed information about all the properties, events and methods of the component.