diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e8134c6f0dd..beb25a3d5fe 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1717,7 +1717,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess // Update index table of files (llx_ecm_files) if ($donotupdatesession == 1) { - $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', 0, $object); + $sharefile = 0; + if ($TFile['type'][$i] == 'application/pdf' && strpos($_SERVER["REQUEST_URI"], 'product') !== false && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) $sharefile = 1; + $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', $sharefile, $object); if ($result < 0) { if ($allowoverwrite) { // Do not show error message. We can have an error due to DB_ERROR_RECORD_ALREADY_EXISTS @@ -1727,13 +1729,6 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess } } - // Update table of files - if ($donotupdatesession == 1) { - $sharefile = 0; - if ($TFile['type'][$i] == 'application/pdf' && strpos($_SERVER["REQUEST_URI"], 'product') !== false && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) $sharefile = 1; - $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', $sharefile); - } - $nbok++; } else { $langs->load("errors");