diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 189cec49f8050ac9635bf19c891f424d48766a7b..0559c7b56daa20bb1188ec62dd7f43ca844b8788 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -762,7 +762,10 @@ class FormFile
 				{
 					// Define relative path used to store the file
 					if (empty($relativepath))
+					{
 						$relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/';
+						if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2).$relativepath;
+					}
 
 					$var=!$var;
 					print '<tr '.$bc[$var].'>';