mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-42566 mod_data: introduced check to ensure the picture supplied is valid
This commit is contained in:
parent
68291f2d57
commit
af9fc21cfd
@ -250,6 +250,13 @@ class data_field_picture extends data_field_base {
|
||||
$content->content = $draftfile->get_filename();
|
||||
|
||||
$file = $fs->create_file_from_storedfile($file_record, $draftfile);
|
||||
|
||||
// If the file is not a valid image, redirect back to the upload form.
|
||||
if ($file->get_imageinfo() === false) {
|
||||
$url = new moodle_url('/mod/data/edit.php', array('d' => $this->field->dataid));
|
||||
redirect($url, get_string('invalidfiletype', 'error', $file->get_filename()));
|
||||
}
|
||||
|
||||
$DB->update_record('data_content', $content);
|
||||
$this->update_thumbnail($content, $file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user