PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Md5 Validator

The Md5 validator checks the content of a transferred file by hashing it. This validator uses the hash extension for PHP with the md5 algorithm. It supports the following options:

  • *: Takes any key or use a numeric array.

    You can set multiple hashes by passing them as an array. Each file is checked, and the validation will fail only if all files fail validation.

Example 422. Using the Md5 Validator

<?php
$upload 
= new Zend_File_Transfer();

// Checks if the content of the uploaded file has the given hash
$upload->addValidator('Md5'false'3b3652f336522365223');

// Limits this validator to two different hashes
$upload->addValidator('Md5',
                      
false,
                      array(
'3b3652f336522365223',
                            
'eb3365f3365ddc65365'));

Zend Framework