@@ -28,6 +28,7 @@ function Form() {
28
28
}
29
29
30
30
const Forms = ( props ) => {
31
+ const maxFileSize = 20 ;
31
32
const navigate = useNavigate ( ) ;
32
33
const [ signers , setSigners ] = useState ( [ ] ) ;
33
34
const [ folder , setFolder ] = useState ( { ObjectId : "" , Name : "" } ) ;
@@ -56,17 +57,17 @@ const Forms = (props) => {
56
57
try {
57
58
let files = e . target . files ;
58
59
if ( typeof files [ 0 ] !== "undefined" ) {
59
- const mb = Math . round ( files [ 0 ] . bytes / Math . pow ( 1024 , 2 ) ) ;
60
- if ( mb > 10 ) {
60
+ const mb = Math . round ( files [ 0 ] . size / Math . pow ( 1024 , 2 ) ) ;
61
+ if ( mb > maxFileSize ) {
61
62
alert (
62
- `The selected file size is too large. Please select a file less than ${ Math . round (
63
- 10
64
- ) } MB`
63
+ `The selected file size is too large. Please select a file less than ${ maxFileSize } MB`
65
64
) ;
65
+ setFileUpload ( [ ] ) ;
66
+ e . target . value = "" ;
66
67
return ;
68
+ } else {
69
+ handleFileUpload ( files [ 0 ] ) ;
67
70
}
68
-
69
- handleFileUpload ( files [ 0 ] ) ;
70
71
} else {
71
72
alert ( "Please select file." ) ;
72
73
return false ;
@@ -114,10 +115,10 @@ const Forms = (props) => {
114
115
const url = file . link ;
115
116
const mb = Math . round ( file . bytes / Math . pow ( 1024 , 2 ) ) ;
116
117
117
- if ( mb > 10 ) {
118
+ if ( mb > maxFileSize ) {
118
119
setTimeout ( ( ) => {
119
120
alert (
120
- `The selected file size is too large. Please select a file less than 10 MB`
121
+ `The selected file size is too large. Please select a file less than ${ maxFileSize } MB`
121
122
) ;
122
123
} , 500 ) ;
123
124
return ;
0 commit comments