Merge pull request #8267 from hregis/7.0_bug5

Fix: check if file name already exists
This commit is contained in:
Laurent Destailleur 2018-03-05 20:44:02 +01:00 committed by GitHub
commit 45898d26a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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');
}
}
} }
} }
} }