UploadFile

Zend\Validator\File\UploadFile checks whether a single file has been uploaded via a form POST and will return descriptive messages for any upload errors.

Note

Zend\InputFilter\FileInput will automatically prepend this validator in it’s validation chain.

Usage Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
use Zend\Http\PhpEnvironment\Request;

$request = new Request();
$files   = $request->getFiles();
// i.e. $files['my-upload']['error'] == 0

$validator = \Zend\Validator\File\UploadFile();
if ($validator->isValid($files['my-upload'])) {
    // file is valid
}
blog comments powered by Disqus