diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index d5a887fd40b..98b1fbd6593 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -992,7 +992,7 @@ class FormFile
$entity = 1; // Without multicompany
// Get object entity
- if (!empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
$regs = array();
preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir, '/').'$/', $filedir, $regs);
$entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default