Index: pro-violet-viettel/www/deploy/api/platform/lib/violetUtil.class.php
===================================================================
--- pro-violet-viettel/www/deploy/api/platform/lib/violetUtil.class.php	(revision 916)
+++ pro-violet-viettel/www/deploy/api/platform/lib/violetUtil.class.php	(revision 918)
@@ -40,5 +40,4 @@
 
    public function createThumb($pathToImage="") {
-
         if (is_file($pathToImage)) {
             $info = pathinfo($pathToImage);
Index: pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php
===================================================================
--- pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php	(revision 916)
+++ pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php	(revision 918)
@@ -181,4 +181,5 @@
 
     private function createPreview($fileurl, $userId, $fileid) {
+        $thumbnail="";
         $url = "https://docs.google.com/gview?url=" . urlencode($fileurl) . "";
         file_put_contents("1.html", $url);
@@ -215,4 +216,11 @@
                     }
                     file_put_contents("previews/" . $userId . "/" . $fileid . "/" . $i . ".png", $image);
+                    if ($count==1)
+                    {
+                    $file_path= str_replace("http://" . $_SERVER['SERVER_NAME'], $_SERVER['DOCUMENT_ROOT'], $fileurl);
+                    $file_path= str_replace(pathinfo($file_path, PATHINFO_EXTENSION), "png", $file_path);
+                    file_put_contents($file_path, $image);    
+                    $thumbnail=violetUtil::createThumb($file_path);
+                    }
                 } else {
                     break;
@@ -220,5 +228,5 @@
             }
         }
-        return $count;
+        return $thumbnail; 
     }
 
@@ -464,7 +472,7 @@
         $ext = pathinfo($fileUrl, PATHINFO_EXTENSION);
         $ext = strtolower($ext);
-
+        $thumbnail="";
         if (in_array($ext, array("ppt", "xls", "doc", "pdf", "docx", "pptx", "xlsx"))) {
-            $this->createPreview($fileUrl, $userId, $tblfile->getFileId());
+            $thumbnail=$this->createPreview($fileUrl, $userId, $tblfile->getFileId());
         }
 
@@ -472,11 +480,11 @@
             $aryError = array('err' => "", 'errCode' => 0);
             $ext = pathinfo($fileUrl, PATHINFO_EXTENSION);
-            $thumbnail = "";
+            if ($thumbnail=="")
+            {
             if (in_array(strtolower($ext), array("jpg", "jpeg", "png", "gif"/* , "tiff", "dvg", "bmp" */))) {
             	$thumbnail=violetUtil::createThumb($filePath);
             }
-            if (file_exists("previews/$userId/" . $tblfile->getFileId() . "/0.png")) {
-                $thumbnail = "previews/$userId/" . $tblfile->getFileId() . "/0.png";
-            }
+            }
+            
             $aryFiles = array(
                 0 => array('id' => $tblfile->getFileId(), 'thumbnail' => $thumbnail, 'fileurl' => $fileUrl, 'name' => $fileName, 'minetype' => $ext, 'size' => $fileSize, 'parentID' => $catId),
Index: pro-violet-viettel/www/deploy/api/platform/modules/space/templates/dirSuccess.php
===================================================================
--- pro-violet-viettel/www/deploy/api/platform/modules/space/templates/dirSuccess.php	(revision 916)
+++ pro-violet-viettel/www/deploy/api/platform/modules/space/templates/dirSuccess.php	(revision 918)
@@ -32,5 +32,5 @@
       $filePath="";
       $thumbnail="";
-      if (in_array($ext, array("jpg","png","jpeg","gif")))
+      if (in_array($ext, array("jpg","png","jpeg","gif","")))
       {
           $names = explode(".", $name);
@@ -38,11 +38,18 @@
           $filePath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $filePath);
           $thumbnail = str_replace($name, "", $fileName). $names[0].'_thumb.'.$ext;
+          $thumbnail=   ltrim ($thumbnail, '/');
       }
       else
       {
-        if (file_exists("previews/$userId/".$tblfile->getFileId()."/0.png"))
-        {
-            $thumbnail="previews/$userId/".$tblfile->getFileId()."/0.png";
-        }
+          $names = explode(".", $name);
+          $filePath = $tblres->getFullFilename();
+          $filePath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $filePath);
+          $thumbnail = str_replace($name, "", $fileName). $names[0].'_thumb.png';
+          $thumbnail=   ltrim ($thumbnail, '/');
+          if (!file_exists($thumbnail)) 
+          {
+              $thumbnail="";
+          }
+          
       }
 
