Created
April 2, 2009 09:51
-
-
Save wmh/89114 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} | |
$image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe'); | |
foreach ($this->allowed_types as $val) | |
{ | |
$mime = $this->mimes_types(strtolower($val)); | |
// Images get some additional checks | |
//if (in_array($val, $image_types)) | |
//FIXED: 僅上傳的檔案為圖檔時,才做圖檔大小的判斷 | |
if (in_array($val, $image_types) && $val == str_replace(".","",$this->file_ext)) | |
{ | |
if (getimagesize($this->file_temp) === FALSE) | |
{ | |
return FALSE; | |
} | |
} | |
if (is_array($mime)) | |
{ | |
if (in_array($this->file_type, $mime, TRUE)) | |
{ | |
return TRUE; | |
} | |
} | |
else | |
{ | |
if ($mime == $this->file_type) | |
{ | |
return TRUE; | |
} | |
} | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment