Dropzone : How to process queue several times - form-submit

I'm using dropzone for uploading files to a servlet. The upload is performed via XMLHttpRequest and works perfectly... but only on first submit.
I would to be able to submit the exact same files several times, but the myDropzone.processQueue() does nothing unless I drop a new file in form or I remove and re-drop same files again (which is not convenient).
How can I make the queue be processed again without modifying the form inputs ?

Related

Initial Files List on demand

I have 6 fineuploader instances in a single page but different tabs (show/hide divs). I do need to display previous session uploaded files, but my challenge is that if all fineuploader instance starts to display in all tabs, it is going to long time for user to see first tab as each uploader instance will have 50-100 images.
My question....is there any trick in which I can trigger the fineUploader init files upon user clicks on the tab?
As of Fine Uploader 5.6.0, you can add initial files to the library at any time with the addInitialFiles API method. So when your user clicks on the tab, you can retrieve your initial files list from the server (or wherever it exists) and then pass this data to addInitialFiles.

Uploading a file stored in browser memory via ajax

Assume there are no cross-domain issues with the ajax calls to the server(s).
First, I am making an ajax call to grab the contents of a binary file (docx) from the server. The contents are then stored in the browser memory.
Next, I need to make another ajax call to the server to upload the file contents along with other form fields. The page may already contains the form, or the js can dynamically create the form (which would be hidden), or I can use the FormData object in the js code.
I can't figure out how to take file contents that are in memory and include them in a form POST call to upload the file along with the other form inputs. Any idea how to do this?
I thought perhaps using the FileReader object I could do this, as I have seen where you can use FileReader.readAsBinaryString() on a blob or binary data, then have the onloadend trigger the form submit.
I would prefer to use jquery, but that is not necessary.

Disable Drag and Drop programatically - fine-uploader

Once a user has uploaded a file via any means (file selection, DnD or Cut and Paste), I would like to disable the Upload widget, to prevent users to upload again.
This disabling should be done for a specific upload widget since I may have many on the same page.
Is there a method I can call to do this?
Thanks.
Simply present an alert/message to the user in your UI once they are no longer able to upload additional files (which you should do no matter what) and then return false in your onValidateBatch handler for all subsequently dropped/selected files. This will prevent files submitted via the file chooser, file submitted via DnD, AND pasted images from being uploaded.

What's the common way to handle AJAX file uploads/preventing orphaned files?

I'm planning to use FineUploader.js to give my users the ability to drag 'n drop images, select multiple at once, etc... and, maybe more importantly, have the image uploading while they complete the rest of a form.
I'll be using the ASP.NET MVC/.NET 4.5/C# platform for this project.
What if the user don't complete the form? If they actually hit a cancel button I could probably fire a command to delete the images that have already uploaded. What about if they simply close the browser?
How to prevent files from being uploaded, but not used?

Can I edit the response object on Ajax call?

I have a link button on my page clicking on which, I download a file from some DMS system and then send the file after zipping it on server to the client using response.write.
But since the page is ajaxified, it throws an error.
Is possible to send a file to the client on a Ajax call?
I am using Telerik RadAjax.
Don't use Response.Write or Response.WriteFile to force file-download because that will simply not help in this context.
In order to do what you want, save the zipped file on disk and redirect the user to download-file. You can create a temp folder to hold the zipped files which you create on the fly and flush them every one hour or any such predefined time-interval. You need to call this from standard post-back driven non-ajaxed call. This will preserve the state.
Response.Redirect("path-file-to-download");
Response.End();
There is no reason to request the file with an AJAX callback, as downloading the file doesn't refresh the page and therefore the user doesn't lose the context, which is usually the reason why you would prefer AJAX callback.
According to your comments, there are 2 ways to overcome the problem :
You can write into the response stream at the same time that you are downloading the file from the second server and therefore making the progress visible in the open/save dialog of the browser.
You can temporarily store the file somewhere in the database / file system and send it with a second request made directly by the user.
The first one seems more reasonable to me as you don't have to deal with the intermediate storage.
You can send whatever data you like, you just have to be able to handle it in your JavaScript.
There isn't a great deal that JavaScript could do with a zipped file (unless you fancy finding, or writing, a zip decompression library in JavaScript).

Resources