Sometimes connection problems occur unexpectedly during the upload of files to server. Such problems cause several inconvenient situations which force users to:
To avoid these situations Image Uploader offers several means to recover the upload process. These means can be configured via the properties of the UploadSettings class. Let us consider them in more detail.
To begin with, we should note that Image Uploader supports hands-free upload recovery by resending the last failed request. Here you just set a number of attempts (AutoRecoveryMaxAttemptCount) and a time interval between them (AutoRecoveryTimeout). Additionally you can use the ReconnectionText property to specify the text that will be shown while Image Uploader waits to reconnect.
Image Uploader Express does not support automatic upload recovery. See the Comparison of Image Uploader Editions topic for details.
However, this method is not so effective because Image Uploader sends all files in a single request by default. It means that in case of a connection problem Image Uploader will resend all selected files, even if it was the last file which has failed. We strongly recommend you to use the multiple requests upload mode along with the automatic upload recovery. This upload mode is described in the Sending All Files at Once or in Several Parts topic. For brevity, we consider the most commonly used configuration of this upload mode: sending each file in a separate package (FilesPerPackage = 1
) and dividing extremely large files into 10 Mb chunks (ChunkSize = 10485760
).
Let us describe the advantages of this configuration. When a user selects small files (lesser than 10 Mb), Image Uploader sends them one by one. And, in case of a connection problem, only the last unsuccessful file will be resent. However, extremely large files (more than 10 Mb) are sent in chunks, which means that Image Uploader will resend only the last chunk while the automatic upload recovery is performed. Though, when Image Uploader has exhausted all attempts, the whole package containing this chunk is considered unsuccessful.
Although you may change the ChunkSize value, you should take into account the following:
It is highly recommended to use Image Uploader ASP.NET or Image Uploader PHP to handle upload on the server side. Both of them automatically bundle pieces of one file, uploaded in separated chunks, and provide an access to this file as if it was uploaded as a whole.
In most cases Image Uploader resumes the upload process automatically; but if it is impossible (the connection problem appears to be permanent), the last uploading package is considered failed. If it happened, the upload list still contains all the unsent files, including the one which was being sent when the upload was broken, and a user can resend them manually (just by clicking Upload one more time).
Besides, you can extend your Image Uploader configuration to make it resistant to deeper problems, for instance, when a page containing Image Uploader is closed or a computer is rebooted or suddenly turned off. By default, such problems cause clearing of the upload list and make a user select all the files again. Fortunately, Image Uploader can save and restore upload list, even if a totally unexpected problem occured. This feature is described in the Restoring Upload List topic.
The code sample below demonstrates how to configure a fail-safe upload.
<aur:Uploader ID="Uploader1" runat="server"> <UploadSettings AutoRecoveryMaxAttemptCount="10" AutoRecoveryTimeout="2000" FilesPerPackage="1" ChunkSize="10485760"/> </aur:Uploader>
$uploader = new Uploader("Uploader1"); $uploader->getUploadSettings()->setAutoRecoveryMaxAttemptCount(10); $uploader->getUploadSettings()->setAutoRecoveryTimeout(2000); $uploader->getUploadSettings()->setFilesPerPackage(1); $uploader->getUploadSettings()->setChunkSize(10485760);
var u = $au.uploader({ id: 'Uploader1', uploadSettings: { autoRecoveryMaxAttemptCount: 10, autoRecoveryTimeout: 2000, filesPerPackage: 1, chunkSize: 10485760 } });