file.calculateHash(Function) Method HTML5/Flash Uploader JavaScript

Supported technologies:

Calculates MD5 hash for a file.





Type: Function

A function which is called when the hash is calculated. The function must receive a single argument - a result hash value.


This function is asynchonous. So you can call it repeatedly and it won't block your script. However, please note, it may be resource intesive if you call if for a large file (tens MB and greater). So if you expect that users may select very large files, consider checking the file size before you call this method.

The hash is calculated only on the first call. Then it is cached and when you call this method one more time, it calls the callback function immediately.

It is convenient using this method if you need receiving the hash value for a file before you upload a file (e.g. to send a separate AJAX request to your server to check whether a file with this hash already exists on the server). If you rather need to send a hash value to the server along with uploaded files, it is recommended using the hash instead.

See Also