| @@ -92,9 +92,19 @@ const PublicNoticeApplyForm = ({loadedData, selections}) => { | |||||
| }); | }); | ||||
| const readFile=(event)=>{ | const readFile=(event)=>{ | ||||
| if(event.target.files[0]){ | |||||
| if(event.target.files[0]) | |||||
| setAttachment(event.target.files[0]); | |||||
| let file = event.target.files[0]; | |||||
| 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" | |||||
| ){ | |||||
| setAttachment(event.target.files[0]); | |||||
| }else{ | |||||
| setWarningText("請上傳有效檔案 (檔案格式: .doc, .docx, .xls, .xlsx)"); | |||||
| setIsWarningPopUp(true); | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -178,7 +188,7 @@ const PublicNoticeApplyForm = ({loadedData, selections}) => { | |||||
| id="uploadFileBtn" | id="uploadFileBtn" | ||||
| name="file" | name="file" | ||||
| type="file" | type="file" | ||||
| accept=".doc,.docx,.xml,.xlsx" | |||||
| accept=".doc,.docx,.xls,.xlsx" | |||||
| style={{ display: 'none' }} | style={{ display: 'none' }} | ||||
| onChange={(event)=> { | onChange={(event)=> { | ||||
| readFile(event) | readFile(event) | ||||