Skip to content

Commit 49facd1

Browse files
author
Jovert Lota Palonpon
committed
[Dropzone] Consumer provided max file count, closes #32
1 parent 13339ec commit 49facd1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

resources/js/ui/Dropzone.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ function Dropzone(props) {
262262
});
263263
}
264264

265+
// If the file count exceeds the maximum, set it as rejected.
266+
if (key + 1 > maxFiles) {
267+
return Object.assign(file, {
268+
status: 'rejected',
269+
message: 'It could not accept more files.',
270+
});
271+
}
272+
265273
return file;
266274
}),
267275
);

resources/js/views/__backoffice/users/Forms/Avatar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class Avatar extends Component {
105105

106106
<Dropzone
107107
initialFiles={files}
108-
maxFiles={2}
109-
maxFileSize={2}
108+
maxFiles={1}
109+
maxFileSize={5}
110110
handleUpload={this.handleUpload}
111111
handleFileRemoved={this.handleFileRemoved}
112112
/>

0 commit comments

Comments
 (0)