Community Support for OpenDocMan (Deprecated)
Mime Type Fix - Printable Version

+- Community Support for OpenDocMan (Deprecated) (https://forum.opendocman.com)
+-- Forum: OpenDocMan Community Discussion (https://forum.opendocman.com/forum-5.html)
+--- Forum: OpenDocMan Patches (https://forum.opendocman.com/forum-10.html)
+--- Thread: Mime Type Fix (/thread-598.html)



Mime Type Fix - plowman - 03-08-2013

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;



Re: Mime Type Fix - Guest - 03-11-2013

i got this error

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

What should i do? :?:


Re: Mime Type Fix - Stephen - 03-11-2013

Sounds like you have a typo. Try grabbing v1.2.6.4, it contains a more permanent attempt at solving the mime issue.


Re: Mime Type Fix - Guest - 03-13-2013

I'm grabbing the latest one but this occur:

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

:?: :?:


Re: Mime Type Fix - Stephen - 03-13-2013

Please try http://www.opendocman.com/opendocman-dms-release-1-2-6-5/

This is 1.2.6.5.


Re: Mime Type Fix - Guest - 03-14-2013

Ok great...
Its all fixed...