diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index d2c2b6d17a3..2243b4e06c1 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -174,14 +174,23 @@ class FormFile
$out .= "";
if ($savingdocmask)
- {
- $out .= '
';
- if (! empty($options)) $out .= '| '.$options.' | ';
- $out .= '';
- $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName"));
- $out .= ' | ';
- $out .= '
';
- }
+ {
+ //add a global variable for disable the auto renaming on upload
+ if (! empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT))
+ {
+ $rename='';
+ }
+ else {
+ $rename='checked';
+ }
+
+ $out .= '';
+ if (! empty($options)) $out .= '| '.$options.' | ';
+ $out .= '';
+ $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/',$langs->transnoentitiesnoconv("OriginFileName"),$savingdocmask), $langs->transnoentitiesnoconv("OriginFileName"));
+ $out .= ' | ';
+ $out .= '
';
+ }
$out .= "";