作者 邓超

bbbbb

@@ -47,7 +47,7 @@ class FileController extends BaseController @@ -47,7 +47,7 @@ class FileController extends BaseController
47 * @time 2023/5/29 11:42 47 * @time 2023/5/29 11:42
48 */ 48 */
49 public function lists(){ 49 public function lists(){
50 - $files = Upload::lists($this->param['config'] ?? 'default'); 50 + $files = Upload::lists($this->param['config'] ?? 'default',['png','jpg','jpeg','gif']);
51 return $this->success($files); 51 return $this->success($files);
52 } 52 }
53 53
@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Facade; @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Facade;
11 * @method static array filePut(string $filename, string $content, string|array $config="default") 11 * @method static array filePut(string $filename, string $content, string|array $config="default")
12 * @method static string url2path(string $url, string|array $disk="upload") 12 * @method static string url2path(string $url, string|array $disk="upload")
13 * @method static string path2url(string $path, string|array $disk="upload") 13 * @method static string path2url(string $path, string|array $disk="upload")
14 - * @method static array lists(string $config) 14 + * @method static array lists(string $config,array $ext=[])
15 */ 15 */
16 class Upload extends Facade 16 class Upload extends Facade
17 { 17 {
@@ -279,8 +279,21 @@ class UploadService extends BaseService @@ -279,8 +279,21 @@ class UploadService extends BaseService
279 * @author:dc 279 * @author:dc
280 * @time 2023/5/29 11:49 280 * @time 2023/5/29 11:49
281 */ 281 */
282 - public function lists($config){ 282 + public function lists($config,array $ext=[]){
283 $this->config($config); 283 $this->config($config);
284 - return Storage::disk($this->config['disk'])->allFiles(); 284 + $lists = Storage::disk($this->config['disk'])->allFiles();
  285 +
  286 +
  287 + if($ext){
  288 + foreach ($lists as $k=>$list){
  289 + $list = explode('.',$list);
  290 + if(!in_array(end($list),$ext)){
  291 + unset($lists[$k]);
  292 + }
  293 + }
  294 + }
  295 +
  296 +
  297 + return $lists;
285 } 298 }
286 } 299 }