';
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index ec1d74d4115..6e8b1cd6340 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -6,7 +6,7 @@
* Copyright (C) 2013 Cédric Salvador
* Copyright (C) 2014 Marcos García
* Copyright (C) 2015 Bahfir Abbes
- * Copyright (C) 2016 Ferran Marcet
+ * Copyright (C) 2016-2017 Ferran Marcet
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -958,10 +958,10 @@ class FormFile
if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2,0,0,$object,'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath
if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.';
}
- // For backward compatiblity, we detect file is stored into an old path
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $file['level1name'] == 'photos')
+ // For backward compatiblity, we detect file stored into an old path
+ if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos')
{
- $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/';
+ $relativepath=preg_replace('/^.*\/produit\//','',$filearray[0]['path']).'/';
}
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 0d6d6f815be..6868005f54f 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -4102,8 +4102,8 @@ class Product extends CommonObject
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $dirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
- $pdirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
+ $dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
+ $pdir = '/' . get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
}
// Defined relative dir to DOL_DATA_ROOT
@@ -4123,11 +4123,11 @@ class Product extends CommonObject
$filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
+ /*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
{
$filearrayold=dol_dir_list($dirold,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$filearray=array_merge($filearray, $filearrayold);
- }
+ }*/
completeFileArrayWithDatabaseInfo($filearray, $relativedir);
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index fd67cd72504..72312aa4643 100644
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -6,6 +6,7 @@
* Copyright (C) 2005 Simon TOSSER
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2013 Cédric Salvador
+ * Copyright (C) 2017 Ferran Marcet
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by