Exemple #1
0
 public function validFileType($ignore_mime = false)
 {
     if ($this->allowed_types == '*') {
         return true;
     }
     if (!$this->allowed_types) {
         $this->addError('No allowed upload filetype is set!');
         return false;
     }
     $ext = strtolower(ltrim($this->file_ext, '.'));
     if (!in_array($ext, $this->allowed_types)) {
         return false;
     }
     // Images get some additional checks
     $image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');
     if (in_array($ext, $image_types)) {
         if (getimagesize($this->file_temp) === false) {
             return false;
         }
     }
     if ($ignore_mime === false) {
         return true;
     }
     $mime = \Clips\mime_types($ext);
     if (is_array($mime)) {
         if (in_array($this->file_type, $mime, true)) {
             return true;
         }
     } elseif ($mime == $this->file_type) {
         return true;
     }
     return false;
 }
 public function testMimeType()
 {
     $this->assertEquals(Clips\mime_types('jpg'), array('image/jpeg', 'image/pjpeg'));
 }