03-07-2013, 08:44 PM
How about something like this, which might handle newer and older systems:
in function.php:
In add.php (for example):
in function.php:
Code:
/**
* Determine the mimetype of a file
* @param file path $filename
* @return string
*/
function getFileMimeType($filename)
{
if (function_exists("finfo_file")) {
// return mime type ala mimetype extension
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mime;
} else if (function_exists("mime_content_type")) {
return mime_content_type($filename);
} else {
return false;
}
}
In add.php (for example):
Code:
// check file type
foreach ($GLOBALS['CONFIG']['allowedFileTypes'] as $thistype)
{
if (getFileMimeType($_FILES['file']['tmp_name'][$count]) == $thistype)
{
$allowedFile = 1;
break;
} else
{
$allowedFile = 0;
}
}