diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 00c5c946326..4958811ef4d 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -524,15 +524,15 @@ if (empty($reshook)) { } /* - * Add file in email form + * Action of adding a file in email form */ - if (!empty($_POST['addfile'])) { + if (GETPOST('addfile')) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp user directory - dol_add_file_process($upload_dir, 0, 0); + dol_add_file_process($upload_dir, 0, 0, 'addedfile', '', null, '', 0); $action = "edit"; } @@ -543,7 +543,7 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process(GETPOST('removedfile'), 0, 0); // We really delete file linked to mailing $action = "edit"; } @@ -1216,7 +1216,7 @@ if ($action == 'create') { $out .= '
'; } } else { - $out .= $langs->trans("NoAttachedFiles").'
'; + $out .= ''.$langs->trans("NoAttachedFiles").'
'; } // Add link to add file $out .= ''; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 431cdffccf4..782b0ec4694 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1544,7 +1544,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess if (!empty($_FILES[$varfiles])) { // For view $_FILES[$varfiles]['error'] dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG); - if (dol_mkdir($upload_dir) >= 0) { + $result = dol_mkdir($upload_dir); + // var_dump($result);exit; + if ($result >= 0) { $TFile = $_FILES[$varfiles]; if (!is_array($TFile['name'])) { foreach ($TFile as $key => &$val) { @@ -1647,6 +1649,8 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $res = 1; setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); } + } else { + setEventMessages($langs->trans("ErrorFailedToCreateDir", $upload_dir), null, 'errors'); } } elseif ($link) { require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';