MDL-33391 Files API, Repository : mimetype should be determined from file extension when possible

This commit is contained in:
Marina Glancy 2012-06-01 12:16:53 +08:00 committed by Aparup Banerjee
parent 66726f61d0
commit efa28f30f2
2 changed files with 2 additions and 2 deletions

View 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);

View 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'])));
}