Fix: check if file name already exists

This commit is contained in:
Regis Houssin 2018-03-02 18:59:30 +01:00
parent 8e85198bd1
commit b69d2800ef

View File

@ -202,6 +202,8 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
$srcpath = $upload_dir.'/'.$filenamefrom; $srcpath = $upload_dir.'/'.$filenamefrom;
$destpath = $upload_dir.'/'.$filenameto; $destpath = $upload_dir.'/'.$filenameto;
if (!file_exists($destpath))
{
$result = dol_move($srcpath, $destpath); $result = dol_move($srcpath, $destpath);
if ($result) if ($result)
{ {
@ -221,6 +223,12 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
} }
} }
else
{
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
}
}
} }
} }
} }