Created
February 17, 2014 12:43
-
-
Save noondreams/9049886 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public function mimeIsAmong( $error_msg ) | |
{ | |
$r_conditions = array( | |
"image/png" , | |
"image/jpg" , | |
"image/jpeg" , | |
"image/gif" , | |
"application/pdf" , | |
"application/msword" , | |
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" ); | |
$oFileInfo = new finfo ( FILEINFO_MIME_TYPE ) ; | |
$sMimeType = $oFileInfo -> file ( "path/to/your/file") ; | |
if ( ! in_array ( $sMimeType , $ar_conditions ) ) | |
{ | |
throw new \Exception("Someone is trying to upload an illegal file. Warn him!!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment