mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'm20_MDL-25215_filepicker_saveas' of git://github.com/dongsheng/moodle
This commit is contained in:
commit
419814db02
1 changed files with 15 additions and 1 deletions
|
@ -105,7 +105,21 @@ class repository_upload extends repository {
|
||||||
if (empty($saveas_filename)) {
|
if (empty($saveas_filename)) {
|
||||||
$record->filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
|
$record->filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
|
||||||
} else {
|
} else {
|
||||||
$record->filename = $saveas_filename;
|
$ext = '';
|
||||||
|
$match = array();
|
||||||
|
$filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
|
||||||
|
if (preg_match('/\.([a-z0-9]+)$/i', $filename, $match)) {
|
||||||
|
if (isset($match[1])) {
|
||||||
|
$ext = $match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ext = !empty($ext) ? $ext : '';
|
||||||
|
if (preg_match('#\.(' . $ext . ')$#', $saveas_filename)) {
|
||||||
|
// saveas filename contains file extension already
|
||||||
|
$record->filename = $saveas_filename;
|
||||||
|
} else {
|
||||||
|
$record->filename = $saveas_filename . '.' . $ext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->mimetypes != '*') {
|
if ($this->mimetypes != '*') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue