reactjsprimereact

PrimeReact Fileupload component clear Fileupload content for custom upload handler


I am using PrimeReact FileUpload and trying to send multiple files using custom file uploader. I was able to upload the files but it is not clearing FileUpload contents and was not able to find any documentation. Is there anyway I could clear the content and disable "Upload" and "Clear" buttons.

<FileUpload name="files" 
            url={url}
            action="post"
            customUpload
            uploadHandler={Upload}
            multiple accept="*/*"
            maxFileSize={100000000 } />
const Upload = (event) => {
        
        event.files.forEach(file=>{
            formData.append("files", file);
          });
        axios({
            method: "POST",
            url: url,
            data: formData,
            headers: {
              "Content-Type": "multipart/form-data",
              
            }
    }).then(res => {
       
      })

I was not able to find any documentation.


Solution

  • FileUpload has a clear method you can call from the ref.

    <FileUpload ref="fileRef" />
    
    
    const fileRef = useRef(null);
    
    fileRef.current.clear();