Browse files

MDL-33391 Files API, Repository : mimetype should be determined from …

…file extension when possible
  • Loading branch information...
1 parent 66726f6 commit efa28f30f2b75116249c1ae5341ad46ad91b93d0 @marinaglancy marinaglancy committed with nebgor Jun 1, 2012
Showing with 2 additions and 2 deletions.
  1. +1 −1 lib/filestorage/stored_file.php
  2. +1 −1 repository/upload/lib.php
View
2 lib/filestorage/stored_file.php
@@ -161,7 +161,7 @@ protected function update($dataobject) {
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);
View
2 repository/upload/lib.php
@@ -171,7 +171,7 @@ public function process_upload($saveas_filename, $maxbytes, $types = '*', $savep
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'])));
}

0 comments on commit efa28f3

Please sign in to comment.