is_allowed_filetype() public method

Verify that the filetype is allowed
public is_allowed_filetype ( boolean $ignore_mime = FALSE ) : boolean
$ignore_mime boolean
return boolean
Example #1
0
 /**
  * Verify that the filetype is allowed
  *
  * @access	public
  * @return	bool
  */
 function is_allowed_filetype()
 {
     if (count($this->allowed_types) == 0 or !is_array($this->allowed_types)) {
         $this->set_error('upload_no_file_types');
         return FALSE;
     }
     // Fix for 'application/octet-stream' problem in SWFUpload
     if ($this->file_type == 'application/octet-stream') {
         $mime = $this->mimes_types(trim($this->file_ext, '.'));
         $this->file_type = is_array($mime) ? $mime[0] : $mime;
     }
     // Match the mime with the actual extension
     $this->file_ext = strtolower($this->file_ext);
     if (CI()->CONF['match_mime_to_ext']) {
         // This will require that the extension of the file uploaded matches against only the extention's mimes
         if (in_array(trim($this->file_ext, '.'), $this->allowed_types)) {
             $mime = $this->mimes_types(trim($this->file_ext, '.'));
             if (is_array($mime) && in_array($this->file_type, $mime, TRUE)) {
                 return TRUE;
             } else {
                 if ($mime == $this->file_type) {
                     return TRUE;
                 }
             }
         }
         return FALSE;
     } else {
         return parent::is_allowed_filetype();
     }
 }
Example #2
0
 /**
  * Verify that the filetype is allowed
  *
  * @access	public
  * @return	bool
  */
 function is_allowed_filetype()
 {
     if ($this->allowed_types = '*') {
         return TRUE;
     } else {
         return parent::is_allowed_filetype();
     }
 }
Example #3
0
 public function is_allowed_filetype($ignore_mime = FALSE)
 {
     $restricted = array('.php', '.php5', '.php4', '.php3', '.phtml', '.pl', '.py');
     if ($this->allowed_types == '*' && in_array($this->file_ext, $restricted)) {
         return FALSE;
     }
     return parent::is_allowed_filetype($ignore_mime);
 }