Calculating MD5 Checksums


Hash Files

To automatically calculate and store the files' MD5 checksum values, so you can verify their integrity, please follow these steps:

 

The "upload.php" script will execute each time a user uploads a file, and it will calculate the file's hash and store it in the file's "Hash" metadata field.

Being a metadata field, you can also display it as a column in the file list view.

Please note that with this method, PHP reads the entire file's contents into memory. This can be slow and might not even work for files larger than PHP's configured "memory_limit" value.

A solution available for Unix type of servers is to replace the line "

$hash = md5(file_get_contents($data['full_path']));

", with the following one:

$hash = exec("md5sum "".escapeshellcmd($data['full_path']).""");

 

 



Article ID: 597
Created On: Thu, Mar 6, 2014 at 7:34 AM
Last Updated On: Wed, Nov 22, 2017 at 9:13 AM
Authored by: KB Admin01 [[email protected]]

Online URL: https://kb.quikbox.com/article.php?id=597