This documentation is for the old version. Go to the latest Upload Suite docs

Robust Upload Sample

This demo application shows how to verify integrity of uploaded files.

Features

The application highlights the following features:

  • Verification of file integrity.
  • Adding custom buttons without extra HTML.
  • Automatic connection recovery.
Note

To find the information about how this demo is implemented using a specific platform, see the Samples by Platforms topic.

Hash value calculation and standard buttons replacement are not yet supported in the Java version of Image Uploader. This version will display unchanged buttons.

Client-Side Code

Adding Hash Calculation

The check, whether the received files contain errors, is performed using hash calculation. To enable it in Image Uploader, set the value of the HashAlgorithm property to the required algorithm name. You can specify several algorithms (as it is done in this application). An appropriate hash value will be calculated and uploaded to the server along with a file. After that you can calculate hash value on the server and compare it with one generated by Image Uploader. For more details about hash calculation, see the Robust Upload Using Hash topic.

Appearance Customization

Robust Upload sample, ActiveX
Figure 1. Application appearance of the ActiveX version.

In this sample, standard Image Uploader buttons are replaced without writing extra HTML code. They are simply replaced with the specified images. To replace the buttons as in this demo, add the following initialization properties:

And to prevent the control from reloading button images every time the user refreshes the page, enable caching of GUI controls using the CacheGuiGraphics property. The property GuiGraphicsVersion holds the version of cached images. If you want to reload them, increase this value. For more details about button replacing, see the Customizing Buttons topic.

Automatic connection recovery

Conditions for automatic connection recovery are specified using the AutoRecoverTimeOut and AutoRecoverMaxTriesCount properties. For more details about connection recovery, see the Configuring Automatic Upload Recovery topic.

Server-Side Code

To complete the upload started by Image Uploader, some actions on the server side should be performed. The upload script of this application is based on to the corresponding script of the Basic Demo Sample. The difference is that the script calculates hash values before saving files. It is done in the following way:

  1. For each uploaded file, the script reads the POST fields that contain hash values. They are HashCodeSHA_1, HashCodeMD5_1, and HashCodeMD2_1 in this sample.
  2. Hash values are re-calculated on the server using standard means of the server platform or third-party libraries.
  3. Values generated on the server and received along with files are compared. If they are not equal, an error will be returned.
  4. If the values are equal, the file will be saved.

See Also

Reference

Samples

Manual