Browse Source

fix bug

master
Anna Ho 1 year ago
parent
commit
7af83172ff
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js

+ 6
- 4
src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js View File

@@ -94,15 +94,17 @@ const PublicNoticeApplyForm = ({loadedData, selections}) => {
const readFile=(event)=>{ const readFile=(event)=>{
let file = event.target.files[0]; let file = event.target.files[0];
if(file){ if(file){
if(file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.documen"
|| file.type == "application/msword"
|| file.type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|| file.type == "application/vnd.ms-excel"
if(file.name.substr(file.name.length - 4).includes(".doc")
|| file.name.substr(file.name.length - 5).includes(".docx")
|| file.name.substr(file.name.length - 4).includes(".xls")
|| file.name.substr(file.name.length - 5).includes(".xlsx")
){ ){
setAttachment(event.target.files[0]); setAttachment(event.target.files[0]);
}else{ }else{
setWarningText("請上傳有效檔案 (檔案格式: .doc, .docx, .xls, .xlsx)"); setWarningText("請上傳有效檔案 (檔案格式: .doc, .docx, .xls, .xlsx)");
setIsWarningPopUp(true); setIsWarningPopUp(true);
setAttachment({});
document.getElementById("uploadFileBtn").value = "";
return; return;
} }
} }


Loading…
Cancel
Save