## Aurigma Image Uploader 7.0.11

# Configuring Fail-Safe Upload

- Collapse All Sections
- See Also
- Language Filter ( all languages )

Sometimes connection problems occur unexpectedly during the uploading of files to server. Such problems cause several inconvenient situations which force users to:

- Resend files manually (by clicking Upload).
- Send already uploaded files again because it is not guaranteed that such files are saved on a server.
- Select and upload all files anew in the case if the computer hangs or the light is switched off.

To avoid these situations Image Uploader offers several possibilities of recovering the upload process. These possibilities can be configured via the properties of the UploadSettings class. Let us consider them in more detail.

Firstly, 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).

Note

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 in itself because Image Uploader sends all the files in one request by default. It means that in the case of the connection problem Image Uploader will resend all the selected files, even if only the last file has failed. So, we strongly recommend you to use the multiple requests upload mode along with the automatic upload recovery. This upload mode is particularly 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 too large files into 10 Mb chunks (ChunkSize = 10485760).

Let us describe advantages of this configuration. When a user selects small files (less than 10 Mb), Image Uploader sends them one by one. And, in the case of the connection problem, only the last unsuccessful file will be resent. On the other hand, too large files (greater than 10 Mb) are sending in chunks. It means that Image Uploader will resend only the last chunck while the automatic upload recovery is performed. However, when Image Uploader has exhausted all attempts, the whole package containing this chunk is considered as unsuccessful.

Although you may change the ChunkSize value, take into account the following:

- The increasing of this value will increase the amount of data which will be resend in the case of connection problem.
- The decreasing of this value will increase the maintenance traffic.

Note

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 the most cases Image Uploader resumes the upload process automatically; but if it is impossible (the connection problem appears permanent), the last uploading package is considered as failed. If it happened, the upload list still contains all the unsent files, including the one which was sending when the upload was broken, and a user can resend them manually (just by clicking Upload one more time).

Additionally, you can extend your Image Uploader configuration to make it resistant to deeper problems, for example, 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 to select all the files again. Fortunately, Image Uploader can save and restore upload list, even if a totally unexpected problem took place. This feature is described in the Restoring Upload List topic.

The code sample below demonstrates how to configure a fail-safe upload.

### ASP.NET

    <aur:Uploader ID="Uploader1" runat="server">
    	<UploadSettings AutoRecoveryMaxAttemptsCount="10"
    		AutoRecoveryTimeout="2000"
    		FilesPerPackage="1"
    		ChunkSize="10485760"/>
    </aur:Uploader>

### PHP

    $uploader = new Uploader("Uploader1");
    $uploader->getUploadSettings()->setAutoRecoveryMaxAttemptsCount(10);
    $uploader->getUploadSettings()->setAutoRecoveryTimeout(2000);
    $uploader->getUploadSettings()->setFilesPerPackage(1);
    $uploader->getUploadSettings()->setChunkSize(10485760);

### JavaScript

    var u = $au.uploader({
    	id: 'Uploader1',
    	uploadSettings: {
    		autoRecoveryMaxAttemptsCount: 10,
    		autoRecoveryTimeout: 2000,
    		filesPerPackage: 1,
    		chunkSize: 10485760
    	}
    });

## See Also

### Reference

- FilesPerPackage Property
- ChunkSize Property
- AutoRecoveryMaxAttemptCount Property
- AutoRecoveryTimeout Property

### Manual

- Sending All Files at Once or in Several Parts
- Saving Uploaded Files in ASP.NET
- Saving Uploaded Files in PHP
- Restoring Upload List

- UploadSettings (ASP.NET)
- UploadSettings (PHP)
- uploadSettings (JavaScript)

- AutoRecoveryMaxAttemptCount (ASP.NET)
- AutoRecoveryMaxAttemptCount (PHP)
- autoRecoveryMaxAttemptCount (JavaScript)

- AutoRecoveryTimeout (ASP.NET)
- AutoRecoveryTimeout (PHP)
- autoRecoveryTimeout (JavaScript)

- FilesPerPackage (ASP.NET)
- FilesPerPackage (PHP)
- filesPerPackage (JavaScript)

- ChunkSize (ASP.NET)
- ChunkSize (PHP)
- chunkSize (JavaScript)

- ChunkSize (ASP.NET)
- ChunkSize (PHP)
- chunkSize (JavaScript)

- FilesPerPackage (ASP.NET)
- FilesPerPackage (PHP)
- filesPerPackage (JavaScript)

- ChunkSize (ASP.NET)
- ChunkSize (PHP)
- chunkSize (JavaScript)

- AutoRecoveryMaxAttemptCount (ASP.NET)
- AutoRecoveryMaxAttemptCount (PHP)
- autoRecoveryMaxAttemptCount (JavaScript)

- AutoRecoveryTimeout (ASP.NET)
- AutoRecoveryTimeout (PHP)
- autoRecoveryTimeout (JavaScript)