2
0
forked from Wavyzz/dolibarr

check if $_FILES['userfile'] is an array before getting values (#26269)

This commit is contained in:
Eric
2023-10-20 02:30:15 +02:00
committed by GitHub
parent e4987c8f3b
commit 0975b2bbb8
4 changed files with 10 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ if (GETPOST('uploadform', 'int') && empty($_POST) && empty($_FILES)) {
// Submit file/link
if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC) && (!isset($permissiontoadd) || $permissiontoadd)) {
if (!empty($_FILES)) {
if (!empty($_FILES) && is_array($_FILES['userfile'])) {
if (is_array($_FILES['userfile']['tmp_name'])) {
$userfiles = $_FILES['userfile']['tmp_name'];
} else {

View File

@@ -102,10 +102,13 @@ if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC))
}
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
if (is_array($_FILES['userfile']['tmp_name'])) {
$userfiles = $_FILES['userfile']['tmp_name'];
} else {
$userfiles = array($_FILES['userfile']['tmp_name']);
$userfiles = [];
if (is_array($_FILES['userfile'])) {
if (is_array($_FILES['userfile']['tmp_name'])) {
$userfiles = $_FILES['userfile']['tmp_name'];
} else {
$userfiles = array($_FILES['userfile']['tmp_name']);
}
}
foreach ($userfiles as $key => $userfile) {

View File

@@ -97,7 +97,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
$checked = '';
//var_dump(GETPOST($file['relativename'])); var_dump($file['relativename']); var_dump($_FILES['userfile']['name']);
// If a file was just uploaded, we check to preselect it
if (is_array($_FILES['userfile']['name'])) {
if (is_array($_FILES['userfile']) && is_array($_FILES['userfile']['name'])) {
foreach ($_FILES['userfile']['name'] as $tmpfile) {
if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) {
$checked = ' checked';

View File

@@ -2221,7 +2221,7 @@ if ($action == 'importsiteconfirm' && $usercanedit) {
$fileofzip = '';
if (GETPOSTISSET('templateuserfile')) {
$fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha');
} elseif (!empty($_FILES)) {
} elseif (!empty($_FILES) && is_array($_FILES['userfile'])) {
if (is_array($_FILES['userfile']['tmp_name'])) {
$userfiles = $_FILES['userfile']['tmp_name'];
} else {