From da2f97134596b7f9955f053e8ae4d27dac631a14 Mon Sep 17 00:00:00 2001
From: florian HENRY <florian.henry@atm-consulting.fr>
Date: Fri, 8 Sep 2017 10:33:00 +0200
Subject: [PATCH] fix upload images on category

---
 htdocs/categories/class/categorie.class.php | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index ecf95c5096d..94113799be9 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -1525,11 +1525,13 @@ class Categorie extends CommonObject
 	 *  Deplace fichier uploade sous le nom $files dans le repertoire sdir
 	 *
 	 *  @param      string	$sdir       Repertoire destination finale
-	 *  @param      string	$file		Nom du fichier uploade
+	 *  @param      string	$files		Nom du fichier uploade
 	 *	@return		void
 	 */
 	function add_photo($sdir, $file)
 	{
+
+
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 		$dir = $sdir .'/'. get_exdir($this->id,2,0,0,$this,'category') . $this->id ."/";
@@ -1542,15 +1544,18 @@ class Categorie extends CommonObject
 
 		if (file_exists($dir))
 		{
-			$originImage = $dir . $file['name'];
+			for ($i=0;$i<=count($file['name']);$i++) {
 
-			// Cree fichier en taille origine
-			dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0);
+				$originImage = $dir . $file['name'][$i];
 
-			if (file_exists($originImage))
-			{
-			    // Create thumbs
-				$this->addThumbs($originImage);
+				// Cree fichier en taille origine
+				dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0);
+
+				if (file_exists($originImage))
+				{
+				    // Create thumbs
+					$this->addThumbs($originImage);
+				}
 			}
 		}
 	}
-- 
GitLab