-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Do not reset input when upload fails (single-upload mode) #985
Conversation
@x-yuri - if you are using it as a native FILE input then the changes in the PR are not correct. For using it like a native file input - the developer should not be setting the When using it as a native file input - you do not set the |
With ajax upload mode... there is one possibility to look for a bit of enhancement - but it will be only for this scenario
This is because ajax mode by nature allows you to queue files... and even if you have If you have challenges - I can try to update over this PR - to achieve the above case with ajax.This will work similar to the avatar upload demo for configuring the plugin (which is for non-ajax mode - which exactly does what you need). |
6b4427c
to
3978315
Compare
a lot of words down below :) First, why do I think it doesn't suit my use case well? I don't really like how file input becomes in control of everything. Generally, you have a form, and file input is just one of the fields. With your plugin (in case of AJAX uploads), you've got file input and it's it you're supposed to provide with information which extra fields to pass. And it's it that is responsible for submitting the form. The plugin has a lot of features, great job there. But honestly, in my opinion better design would be to have one plugin for file input, one for preview area. And give back to form control over when to submit, what to submit, whatever. That would make it less monolithic, easier to change. But we're getting out of scope of this PR here. The question is, do we want to support my use case? Speaking of which, let me describe it in more details first. I've got a list of records on a page, which are basically images with extra data (think Instagram). User can add records. For that it clicks Add button, modal appears where it fills in a form, and submits it. I can't use plain form submission, I need AJAX. Since some fields might not pass validation. And if I were to use plain form submission, I would need to redisplay the modal after showing the page again. Which is probably possible, but AJAX would make it easier.
Not sure if I follow you here. You're saying that only one specific usage scenario has room for improvement. Basically, that is the use case when user can select only one file. And here I agree. We could probably include
Under conditions you provided, you can set
That is needed only for
Why But upon investigation, it appeared, that
I can see that with So, briefly I see the need to specialcase
Feel free to change my PR in any way. But let us probably discuss it first, to make sure we're on the same page.
I just tried creating an album on Facebook. I click on Create Album button. It asks me to select files. After which they're displayed in a popup. If any of them is too big, it's shown as a box with corresponding message. I can add more photos, but I can't retry to upload photos I selected in the beginning. After I decided with which photos I post, and optionally gave them titles, I click Post button. So the answer to your question is probably, no. It doesn't allow to retry uploads. But the workflow there is slightly different. You upload files, then you get a preview where you can amend things, and after that you can apply changes. And we were discussing doing all of that in one step. Or so I believe. You choose files, provide some extra info, then click Submit. After which form validation might fail, and you'll be presented with the same form. |
This is more to do with the native HTML file input restrictions and nothing to do with the plugin. The native file input does not allow manipulation via javascript nor queuing and remembering multiple batches of files - nor does it allow setting values to a native file input via javascript. So if you want to use a traditional form submission - you can configure the plugin without However if you need the other features and methods to control your file uploads (as provided in ajax mode) - this will need to be a slightly different configuration for you as a developer. The plugin rather provides you a closest way to the above to have best of both in ajax mode and use your form inputs as you have and set plugin as a file uploader in parallel but just set your form input values to be returned within If you have other JS or client validations that are called on your otherwise form submit - you could trigger all that validations in your filepreupload or filebatcpreupload events and return |
Yes this is not mandatory. This can be set to |
Precisely my point - this is true for most HTML5 based file uploaders out there ... the only difference is how you as a developer needs to program your code for the UI logic and server logic to achieve your app's use case. |
Do we have anything left to do in this PR?
This must be for multi-upload scenario, which we doesn't deal with in this PR, I believe.
We seem to agree that only the first condition is relevant. Which is taken care of in this PR. Anything I'm missing? |
No... nothing much pending.. thinking to probably to add another property to handle this scenario... |
Thanks @x-yuri have merged your PR code. |
Refer #1048 for a better enhancement to handle this for even multiple files. |
Scope
This pull request includes a
Changes
The following changes were made
Related Issues
Multiple Ajax Upload does not resend the file after an error
Input file is reset when upload fails
Discussion
It's not finished yet. What's left is to fix the preview part. But... do we need that for use case at hand (not just uploading files, but form with a file input)? Your plugin allows to have some fixed (initial) thumbs, that doesn't get overwritten. Thumb list may act as a log (keeps everything you selected or uploaded). And whatnot. But for forms with file inputs even preview might not be necessary. Or if necessary, that would generally be just one image in overwrite mode, so to say. What do you say?