react-images-upload icon indicating copy to clipboard operation
react-images-upload copied to clipboard

Single image option not working

Open simdani opened this issue 7 years ago • 6 comments

singleImage prop is still not working correctly when you set it to true, it still lets upload multiple images.

simdani avatar Oct 21 '18 17:10 simdani

any update on this one

bilal68 avatar Nov 12 '18 17:11 bilal68

This Issue is very closely related to Issue #59 , I left a comment there.

dmitrijBerg avatar Nov 24 '18 13:11 dmitrijBerg

So far my best quick fix is to add display: 'none' to the buttonStyles prop if there are 1 or more images. This way the button does not appear.

taylorgannon avatar Jun 26 '19 21:06 taylorgannon

Hi! i've been facing the same problem right now and i've found a better/complementary trick...

if you use this css :

.uploadPictureContainer:not(:last-of-type) {
    display: none;
}

only the last selected image will show in the preview, allowing the user to change he's mind and choose an other image whitch visualy will replace previous one. you just need to fix your internal code to only use the last file from the pictures array.

Hope it helps :]

oranefayer avatar Sep 03 '19 09:09 oranefayer

Only issue with using display: none is that if a user deletes the last addition, the old one re-appears. The one that worked best for me was to disable the button when the first image is added:

document.getElementsByClassName("chooseFileButton")[0].disabled = true;

And to make sure your users know that only 1 file is permitted, you can mention that in the label of the ImageUploader component.

edmarjsg avatar Nov 09 '19 18:11 edmarjsg

Actual

beautyfree avatar Nov 17 '19 02:11 beautyfree