bytescale / bytescale-upload-widget

Beautiful JavaScript Upload Widget | Powered by Bytescale
https://www.bytescale.com/docs/upload-widget
MIT License
99 stars 10 forks source link

`maxFileCount` not working #19

Closed huynguyen93 closed 2 years ago

huynguyen93 commented 2 years ago

I set maxFileCount = 2 but I can still upload more than 2 images

https://codepen.io/upload-js/pen/QWOZWZR?editors=1010

ljwagerfield commented 2 years ago

Hi @huynguyen93,

Thank you for raising!

The issue I believe you're experiencing is when you upload all the files as a single drop-and-drop batch, rather than one by one. In this case, the drop-and-drop batch size can be larger than the maxFileCount.

This has been resolved in this commit and has been released in 1.47.0, a long with several other fixes:

Please let me know if this resolves your issue 😄

huynguyen93 commented 2 years ago

No, I clicked the button “Upload an image” to upload, not drag-and-drop. But even so, I think the behavior should be: no files are uploaded at all, and an error message is shown.

huynguyen93 commented 2 years ago

Also, when maxFileCount > 1, the button label should be Upload images

huynguyen93 commented 2 years ago

Hi @huynguyen93,

Thank you for raising!

The issue I believe you're experiencing is when you upload all the files as a single drop-and-drop batch, rather than one by one. In this case, the drop-and-drop batch size can be larger than the maxFileCount.

This has been resolved in this commit and has been released in 1.47.0, a long with several other fixes:

  • Cropper not initializing correctly for subsequent images.
  • The "X of Y images" header above the cropper causes the image to shift down when it's displayed (i.e. after the 2nd+ image uploads, and you still have the cropper open on the 1st image).

Please let me know if this resolves your issue smile

Thanks, I've tested again, set maxFileCount = 2, then upload 3 images, only first 2 ones are uploaded -> better than before!

ljwagerfield commented 2 years ago

Also, when maxFileCount > 1, the button label should be Upload images

From 1.48.0 we've started automatically setting multi: true if it's not explicitly specified and maxFileCount > 1, which will have the effect you're mentioning. If it's specifically to do with the wording re. when multi: true, then that's more to do with the locale which you can override yourself.

Thanks, I've tested again, set maxFileCount = 2, then upload 3 images, only first 2 ones are uploaded -> better than before!

If you're happy with truncating, rather than denying the entire batch, then we'll close the issue 😄