|
@@ -4,6 +4,7 @@ namespace App\Service\Wx;
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
+use Illuminate\Support\Facades\Storage;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -131,4 +132,18 @@ class Service
|
|
|
|
|
|
return [false,'操作频繁, 请在 ' . $ttl . '秒后重试'];
|
|
|
}
|
|
|
+
|
|
|
+ public function delStorageFile($old, $new = [], $dir = "upload_files/"){
|
|
|
+ foreach ($old as $value){
|
|
|
+ if(! in_array($value, $new)){
|
|
|
+ $filename_rep = "/api/uploadFiles/";
|
|
|
+ $filename = str_replace($filename_rep, "", $value);
|
|
|
+ $filePath = $dir . $filename;
|
|
|
+ if (Storage::disk('public')->exists($filePath)) {
|
|
|
+ // 文件存在 进行删除操作
|
|
|
+ Storage::disk('public')->delete($filePath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|