MDL-33391 Files API, Repository : mimetype should be determined from file extension...
authorMarina Glancy <marina@moodle.com>
Fri, 1 Jun 2012 04:16:53 +0000 (12:16 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 5 Jun 2012 05:29:07 +0000 (13:29 +0800)
lib/filestorage/stored_file.php
repository/upload/lib.php

index c936716..75ab483 100644 (file)
@@ -161,7 +161,7 @@ class stored_file {
                 throw new file_exception('storedfilecannotread', '', $pathname);
             }
         }
-        $mimetype = $this->fs->mimetype($pathname);
+        $mimetype = $this->fs->mimetype($pathname, $this->file_record->filename);
         $this->file_record->mimetype = $mimetype;
 
         $DB->update_record('files', $this->file_record);
index fa7eaf3..a307ab6 100644 (file)
@@ -171,7 +171,7 @@ class repository_upload extends repository {
 
         if ($this->mimetypes != '*') {
             // check filetype
-            $filemimetype = file_storage::mimetype($_FILES[$elname]['tmp_name']);
+            $filemimetype = file_storage::mimetype($_FILES[$elname]['tmp_name'], $record->filename);
             if (!in_array($filemimetype, $this->mimetypes)) {
                 throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $_FILES[$elname]['name'])));
             }