cqpCow há 8 meses atrás
pai
commit
8bac7d6d2b
1 ficheiros alterados com 8 adições e 5 exclusões
  1. 8 5
      app/Service/FileUploadService.php

+ 8 - 5
app/Service/FileUploadService.php

@@ -106,10 +106,12 @@ class FileUploadService extends Service
             $date = \DateTime::createFromFormat('Ymd', $timestamp);
             $date = $date->format('Y-m-d');
             $dir = FileUploadService::tmp_dir . '/' . $date . '/' . $filename;
-            $realPath = storage_path() . "/app/public/" . $dir;
-            $savePath = self::string3 . $date . '/' . $filename;
-            list($status,$msg) = (new OssService())->uploadFile($realPath,$savePath);
-            if($status) Storage::disk('public')->delete($dir);
+            if(Storage::disk('public')->exists($dir)){
+                $realPath = storage_path() . "/app/public/" . $dir;
+                $savePath = self::string3 . $date . '/' . $filename;
+                list($status,$msg) = (new OssService())->uploadFile($realPath,$savePath);
+                if($status) Storage::disk('public')->delete($dir);
+            }
         }
     }
 
@@ -144,8 +146,9 @@ class FileUploadService extends Service
         $date = \DateTime::createFromFormat('Ymd', $timestamp);
         $date = $date->format('Y-m-d');
         $dir = FileUploadService::tmp_dir . '/' . $date . '/' . $filename;
-        $realPath = storage_path() . "/app/public/" . $dir;
+        if(! Storage::disk('public')->exists($dir)) return;
 
+        $realPath = storage_path() . "/app/public/" . $dir;
         foreach ($file['img_list'] as $filename){
             $filename_tmp = str_replace(FileUploadService::string.FileUploadService::string2,'', $filename);
             $savePath = self::string3 . $date . '/' . $filename_tmp;