Skip to content

Commit 3a26922

Browse files
committed
fix(filefield): check all files, not only one
Signed-off-by: btry <tbugier@teclib.com>
1 parent ebfbd95 commit 3a26922

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

inc/fields/filefield.class.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,15 @@ public function isValid($value) {
6969

7070
if (is_array($_POST['_formcreator_field_' . $this->fields['id']])
7171
&& count($_POST['_formcreator_field_' . $this->fields['id']]) > 0) {
72-
$file = current($_POST['_formcreator_field_' . $this->fields['id']]);
73-
if (is_file(GLPI_TMP_DIR . '/' . $file)) {
74-
return true;
72+
foreach ($_POST['_formcreator_field_' . $this->fields['id']] as $file) {
73+
if (!is_file(GLPI_TMP_DIR . '/' . $file)) {
74+
Session::addMessageAfterRedirect(__('A required file is missing:', 'formcreator') . ' ' . $this->fields['name'], false, ERROR);
75+
return false;
76+
}
7577
}
7678
}
7779

78-
Session::addMessageAfterRedirect(__('A required file is missing:', 'formcreator') . ' ' . $this->fields['name'], false, ERROR);
79-
return false;
80+
return true;
8081
}
8182

8283
public static function getName() {

0 commit comments

Comments
 (0)