03-08-2013, 10:52 AM
Here is fix for some mime problems we have been having:
functions.php
add.php
check-in.php
functions.php
Code:
--- HEAD
+++ Modified In Working Tree
@@ -790,3 +790,27 @@
$GLOBALS['debug_text'] .= $file . ': Line #' . $line . ": ". $query . '<br />';
}
}
+
+/**
+ *
+ * Determine the mimetype of a file
+ * @param string $file_tmp_name File tmp location
+ * @param string $file_type File type
+ * @return string
+ */
+function getFileMimeType($file_tmp_name, $file_type)
+{
+ if (function_exists("finfo_file")) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
+ $mime = finfo_file($finfo, $file_tmp_name);
+ finfo_close($finfo);
+ return $mime;
+ } else if (function_exists("mime_content_type")) {
+ return mime_content_type($file_tmp_name);
+ } else if (in_array($file_type, $GLOBALS['CONFIG']['allowedFileTypes'])) {
+ $mime = $file_type;
+ return $mime;
+ } else {
+ return 'application/octet-stream';
+ }
+}
add.php
Code:
// check file type
foreach ($GLOBALS['CONFIG']['allowedFileTypes'] as $thistype)
{
- if (mime_content_type($_FILES['file']['tmp_name'][$count]) == $thistype)
- {
+
+ if (getFileMimeType($_FILES['file']['tmp_name'][$count], $_FILES['file']['type'][$count]) == $thistype) {
$allowedFile = 1;
break;
check-in.php
Code:
// check file type
foreach($GLOBALS['CONFIG']['allowedFileTypes'] as $thistype)
{
- if (mime_content_type($_FILES['file']['tmp_name'][$count]) == $thistype)
+ if (getFileMimeType($_FILES['file']['tmp_name'], $_FILES['file']['type']) == $thistype)
{
$allowedFile = 1;
break;