PhpRiot
Follow phpriot on Twitter
Sponsored Link
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
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

IsImage Validator

The IsImage validator checks if a transferred file is a image file, such as gif or jpeg. This validator is based on the MimeType validator and supports the same methods and options. You can limit this validator to particular image types with the methods described there.

Example 407. Using the IsImage Validator

<?php
$upload 
= new Zend_File_Transfer();

// Checks whether the uploaded file is a image file
$upload->addValidator('IsImage'false);

// Limits this validator to gif files only
$upload->addValidator('IsImage'false, array('application/gif'));

// Limits this validator to jpeg files only using a simpler notation
$upload->addValidator('IsImage'false'jpeg');

Note

Note that there is no check if you set a MIME type that is not an image. For example, it would be possible to define zip files to be accepted by this validator. Using the 'MimeType' validator for files which are not images will result in more readable code.

Zend Framework