src/bulletproof.php
protected function contraintsValidator()
    {
      /* check image for valid mime types and return mime */
      $this->getImageMime($this->_files['tmp_name']);
      /* validate image mime type */
      if (!in_array($this->mime, $this->mimeTypes)) {
        $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_06'], implode(', ', $this->mimeTypes));
        return false;
      }

      /* get image sizes */
      list($minSize, $maxSize) = $this->size;

      /* check image size based on the settings */
      if ($this->_files['size'] < $minSize || $this->_files['size'] > $maxSize) {
        $min = $minSize.' bytes ('.intval($minSize / 1000).' kb)';
        $max = $maxSize.' bytes ('.intval($maxSize / 1000).' kb)';
        $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_07'], $min, $max);
        return false;
      }

      /* check image dimension */
      list($maxWidth, $maxHeight) = $this->dimensions;
      $this->width = $this->getWidth();
      $this->height = $this->getHeight();

      if ($this->height > $maxHeight || $this->width > $maxWidth) {
        $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_08'], $maxHeight, $maxWidth);
        return false;
      }

      return true;
    }
protected function contraintsValidator()
    {
      /* check image for valid mime types and return mime */
      $this->getImageMime($this->_files['tmp_name']);
      /* validate image mime type */
      if (!in_array($this->mime, $this->mimeTypes)) {
        $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_06'], implode(', ', $this->mimeTypes));
        return false;
      }

      /* get image sizes */
      list($minSize, $maxSize) = $this->size;

      /* check image size based on the settings */
      if ($this->_files['size'] < $minSize || $this->_files['size'] > $maxSize) {
        $min = $minSize.' bytes ('.intval($minSize / 1000).' kb)';
        $max = $maxSize.' bytes ('.intval($maxSize / 1000).' kb)';
        $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_07'], $min, $max);
        return false;
      }

      /* check image dimension */
      list($maxWidth, $maxHeight) = $this->dimensions;
      $this->width = $this->getWidth();
      $this->height = $this->getHeight();

      if ($this->height > $maxHeight || $this->width > $maxWidth) {
        $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_08'], $maxHeight, $maxWidth);
        return false;
      }

      return true;
    }
protected function contraintsValidator ( ) { /* check image for valid mime types and return mime */ $ this -> getImageMime ( $ this -> _files [ 'tmp_name' ] ) ; /* validate image mime type */ if ( ! in_array ( $ this -> mime , $ this -> mimeTypes ) ) { $ this -> error = sprintf ( $ this -> commonUploadErrors [ $ this -> language ] [ 'ERROR_06' ] , implode ( ', ' , $ this -> mimeTypes ) ) ; return false ; } /* get image sizes */ list ( $ minSize , $ maxSize ) = $ this -> size ; /* check image size based on the settings */ if ( $ this -> _files [ 'size' ] < $ minSize || $ this -> _files [ 'size' ] > $ maxSize ) { $ min = $ minSize . ' bytes (' . intval ( $ minSize / 1000 ) . ' kb)' ; $ max = $ maxSize . ' bytes (' . intval ( $ maxSize / 1000 ) . ' kb)' ; $ this -> error = sprintf ( $ this -> commonUploadErrors [ $ this -> language ] [ 'ERROR_07' ] , $ min , $ max ) ; return false ; } /* check image dimension */ list ( $ maxWidth , $ maxHeight ) = $ this -> dimensions ; $ this -> width = $ this -> getWidth ( ) ; $ this -> height = $ this -> getHeight ( ) ; if ( $ this -> height > $ maxHeight || $ this -> width > $ maxWidth ) { $ this -> error = sprintf ( $ this -> commonUploadErrors [ $ this -> language ] [ 'ERROR_08' ] , $ maxHeight , $ maxWidth ) ; return false ; } return true ; }
Validate image size, dimension or mimetypes

@return boolean
Validate image size dimension or mimetypes