mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-33391 Files API, Repository : mimetype should be determined from file extension when possible
This commit is contained in:
parent
66726f61d0
commit
efa28f30f2
@ -161,7 +161,7 @@ class stored_file {
|
|||||||
throw new file_exception('storedfilecannotread', '', $pathname);
|
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;
|
$this->file_record->mimetype = $mimetype;
|
||||||
|
|
||||||
$DB->update_record('files', $this->file_record);
|
$DB->update_record('files', $this->file_record);
|
||||||
|
@ -171,7 +171,7 @@ class repository_upload extends repository {
|
|||||||
|
|
||||||
if ($this->mimetypes != '*') {
|
if ($this->mimetypes != '*') {
|
||||||
// check filetype
|
// 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)) {
|
if (!in_array($filemimetype, $this->mimetypes)) {
|
||||||
throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $_FILES[$elname]['name'])));
|
throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $_FILES[$elname]['name'])));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user