jasny / bootstrap

The missing components for your favorite front-end framework.
https://www.jasny.net/bootstrap/
Apache License 2.0
2.68k stars 496 forks source link

Multiple File Input #605

Closed AlexxMart closed 5 years ago

AlexxMart commented 5 years ago

I'm using the Material Kit Pro V2.1.1 that comes with Jasny Bootstrap v3.1.3.

In one part I'm trying to upload several files, which must appear in the same screen, and when I upload the files for one field it shows the same preview on all fields and if I remove one file from one inputs it gets deleted on all of them.

AlexxMart commented 5 years ago

I actually ended up implementing my own custom method without the library. If someone can give me a small explanation on how this is implemented I can fix it and create a Pull Request, I see this has been a recurring issue for a while with multiple users.

jasny commented 5 years ago

@AlexxMart

Uploading doesn't happen via AJAX. The <input type="file"> element exists, but is just hidden. As such it works as a normal form post. This is the major difference/benefit between this implementation vs any other JavaScript file component.

I don't know if it's possible to support deselecting some of the files, without having to resolve to uploading files via AJAX. If you have a fix that keeps it a regular form post I'm happy to put it in.

AlexxMart commented 5 years ago

Yes, I was doing a form that has from 3 to N amount of files inputs, I notice that if I upload one picture that same files uploads to the other inputs in the form even though those weren't selected.

I will have to take a look at the code to know how to support deselecting some of the files

jasny commented 5 years ago

@AlexxMart The plugin doesn't affect elements that are not children of the fileinput element (with [data-provides="fileinput"]). If that isn't the case, something's wrong with the setup.

Within the file input element you can have an element with [data-dismiss="fileinput"] which clears the file upload. However as said, it's not possible to clear individual files from multi-file select input. You could select the files one by one, but that's probably not what you're looking for.

I'm going to close this issue as unfixable.