admin管理员组

文章数量:1122832

In this handleFileEvent function when selecting multiple files it should display the message "Multiple Files Not Allowed" but not sure why the message is not displaying.

const handleFileEvent = (e: any) => {
    const chooseFiles = Array.from(e.target.files);
    if (chooseFiles.length > 1) {
      ShowToastMessage('Warning', "Can't choose multiple files");
    } else {
      handleUploadFiles(chooseFiles);
      e.target.value = '';
      console.log(chooseFiles);
    }
  }

  const handleUploadFiles = (files: any) => {
    const uploaded = [...uploadfile]
    files.some((file: any) => {
      const fileName = file.name.toLowerCase()
      const fileExtension = fileName.slice(((fileName.lastIndexOf('.') - 1) >>> 0) + 2)
      if (allowedExtensions.includes(fileExtension)) {
        if (uploaded.findIndex((f: any) => f.name === file.name) === -1) {
          uploaded.push(file)
        }
      } else {
        ShowToastMessage(
          'Warning',
          `${file.name} is not allowed. Allowed extensions: 3gp,aac,act,aiff,amr,ape,au,avi,awb,bdvm,bmp,dat,dct,dds,dib,doc,docx,dss,dvf,dvr-ms,eml,flac,flv,gif,gsm,html,ifo,iklax,ivs,jfif,jpe,jpeg,jpg,m2ts,m4a,m4p,m4v,mht,mkv,mmf,mov,mp3,mp4,mpc,mpeg,mpg,msg,msv,mts,oga,ogg,ogm,ogv,opus,pdf,pjpeg,png,pps,ppt,pptx,qt,ra,raw,rm,rtf,sbe,sln,tga,tif,tiff,ts,tta,txt,vox,wav,webm,wma,wmv,wtv,wv,xls,xlsx,x-png,csv`,
          ToastMessageType.Warning,
        )
      }
    })
    const e = { ...gridHelper.entities }
    e['uploadfiles'] = uploaded
    gridHelper.setEntities(e)
    setUploadfiles(uploaded)
  }

本文标签: reactjsthe Toast message in the given function is not showning in the UIStack Overflow