Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mime Type Fix
#1
Here is fix for some mime problems we have been having:

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;
#2
i got this error

Parse error: syntax error, unexpected end of file in ...\opendocman\add.php on line 881

What should i do? :?:
#3
Sounds like you have a typo. Try grabbing v1.2.6.4, it contains a more permanent attempt at solving the mime issue.
#4
I'm grabbing the latest one but this occur:

Fatal error: Class 'Kohana' not found in ...\opendocman\File_class.php on line 72

:?: :?:
#5
Please try http://www.opendocman.com/opendocman-dms...e-1-2-6-5/

This is 1.2.6.5.
#6
Ok great...
Its all fixed...


Forum Jump:


Users browsing this thread: 1 Guest(s)