dongsheng8158 2018-07-02 20:54
浏览 56
已采纳

如何使用Laravel搜索上传的文件?

How do I can search through uploaded files with Laravel by pattern?

I tried Storage::files('uploads/daisjdas09js_*')

do not works

I know, i can get all files as array and then filter out, also i can each upload register to database and then search from database.

Is worth it create table? Or array filter do not takes to much memory?

Laravel version is 5.3

  • 写回答

1条回答 默认 最新

  • dongshi6969 2018-07-03 15:07
    关注

    According to the doc at FileSystem:

    enter image description here

    Its clear that, using Storage::files() would return the Files list in that directory as a string or file path/name:

    given you something like:

    array:3 [▼
      0 => "evaluation/.DS_Store"
      1 => "evaluation/sample.json"
      2 => "evaluation/sample_text.txt"
    ]
    //note it excludes the subdirectories and files in subdirectories
    

    If you want all the file lists also in subdirectories then use Storage::allFiles($directory).

    Since you now have it you can then do the check based on the returned values, then do the filter by your self.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里