【问题标题】:Get file list in a dynamic directory Laravel 5获取动态目录中的文件列表 Laravel 5
【发布时间】:2017-06-16 11:38:16
【问题描述】:

我的../storage/app/public 中有一个这样的文件夹结构

public --2017 --January --Master.xls --File1.xls --File2.xls --February --March --... --December --2018 --2019

我有一个html form,允许用户使用dropdown input 按钮选择年份和月份。
现在我的问题是,如何根据用户的年份和月份选择显示目录中的文件列表(例如一月)?

我发现这个问题与 In Laravel 5, how can I obtain a list of all files in a public folder? 类似,但对我来说仍然不够清楚。

【问题讨论】:

    标签: php laravel laravel-5


    【解决方案1】:

    Storage::files($directory) 将获取特定目录下的所有文件。只需构造目录变量即可。

    $directory = 'app/public/'.$year.'/'.$month;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-12
      • 1970-01-01
      • 2015-11-30
      • 2010-12-26
      • 1970-01-01
      • 2014-06-06
      相关资源
      最近更新 更多