## Aurigma Image Uploader 7.0.28

# Configuring Fail-safe Upload

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

Sometimes connection problems occur unexpectedly during the upload 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 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).

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 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:

- The increase of this value will increase the amount of data which will be resent in case of a connection problem.
- The decrease of this value will increase the overhead 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 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.

### 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)