Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Collection Upload] Cannot upload multiple files in sync-mode #8

Open
ioleo opened this issue Oct 13, 2014 · 11 comments
Open

[Collection Upload] Cannot upload multiple files in sync-mode #8

ioleo opened this issue Oct 13, 2014 · 11 comments

Comments

@ioleo
Copy link
Member

ioleo commented Oct 13, 2014

Seems like something was broken, when we modified the code for async upload.

In synchronous mode, when you add more than 1 file, the file get replaced (instead of added).

This bug disappears when switching to async mode.

@sescandell Any ideas what might cause this? Maybe somewhere the file list is cleared? It shouldn't be for SYNC mode.

@sescandell
Copy link
Member

I'll check it quickly.

I know everything was working... some times ago. Let me some time to check this out,

@ioleo
Copy link
Member Author

ioleo commented Oct 13, 2014

@sescandell It behaves as if on "add file" the current "files selected for upload" list was cleared.

@sescandell
Copy link
Member

Hi @loostro

Could you please give me additional informations about your issue? I think I firstly missunderstood something and just forget something about the CollectionUpload behavior.

If your point is "I'm not able to add multiple files from different directories in SYNC-mode" actually this is "not really a bug" but a limitation to HTML5 file input.

My point is, I just run the project sescandell/CollectionUplaodSample and Sync mode is working (given the limitations of selecting files from the same directory).
Take a look to the documentation here: https://github.com/symfony2admingenerator/AvocodeFormExtensionsBundle/blob/abb714c44b9edd95d82e82a19480ef564181afa8/Resources/doc/collection-upload/async-mode.md#1-description

CollectionUploadType is, by default, configured to upload selected files when form is submited. With asynchronous mode, you can pre-upload files and speed up form submission. Other advantages are, in asynchronous upload, you can select files from different folders (something you cannot done with sync mode).

Maybe this is not clear enough and should be clearly explained in another part of the documentation (like a new "chapter" "Known limitations").

If the issue you encountered is different, let me know :)

@sescandell
Copy link
Member

@ioleo
Copy link
Member Author

ioleo commented Oct 13, 2014

@sescandell actually, my issue was selecting multiple files in the same directory, which I expected to work... but switching to async mode is actually quite easy and it fixes all problems :)

@sescandell
Copy link
Member

Well... I "miss expressed myself".

One "strange" behavior is the following:

  • Adding a file from folder A
  • Validate
  • Adding another file from A
  • Validate

Only the second file will be listed in the collection. This is because of the same limitation if the input file. When you select a second time some files, the input is like "reseted" before files are added. Something that should work is add all files at once from folder A (of course speaking of SYNC mode).

@ioleo
Copy link
Member Author

ioleo commented Oct 13, 2014

So.. it's not a bug.. but a limitation of HTML input, which does not occur in ASYNC mode, becouse we "add" the files into multiple inputs, right?

@sescandell
Copy link
Member

Yes... a kind of... It doesn't appear in ASYNC mode because, on that specific case, I store files in JS memory and process them. We don't rely anymore on the file input API.

Matter is HTML5 API is "read only" (for security reason, otherwise you would be able to add "any" file to uploads). We can't manipulate it to add files from JS. So in SYNC mode, when you click on the "browse" button and validate your choice, it simply clears the list and adds the selected files to the input (when you click on browse then cancel, it simply clear the list).

Maybe we need to be clearer on that specific point :)

My mistake, there was a long time I didn't work on that and totally forget all of this (but now I'm thinking about it, I remember how much time I waste trying to find something to make it working...)

@ioleo
Copy link
Member Author

ioleo commented Oct 13, 2014

Well, if I remember correct, the first version of this widget relied on HTML inputs and it created 1 input per file. So when you clicked "select" the input with selected file was moved (to the selected files list) and under the "add" button, a new (empty) input was created/copied.

But I'm not sure it worked 100%, I remember some issues with multiple file selecting.

So.. for SYNC mode we could remove the individual "cancel" buttons (leave only "cancel all" button), but selecting multiple files in the same directory should be fixed.

@sescandell
Copy link
Member

So.. for SYNC mode we could remove the individual "cancel" buttons (leave only "cancel all" button)

Agree with you

but selecting multiple files in the same directory should be fixed.

If you want to fix this behavior, you can't rely on "one input to handle all files" (the input file multiple="true" option). You need to make something based on, as you proposed, dynamically duplicating inputs.

@ioleo
Copy link
Member Author

ioleo commented Oct 13, 2014

Since we're short on time and this can be fixed by switching to ASYNC mode, I'll leave it as low priority issue to be fixed later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants