LoginSignup
0
0

More than 3 years have passed since last update.

laravel 5.7 フォルダの中身を取得

Posted at

laravel で フォルダの中身を取得したい。


        $files = \File::allFiles(public_path("img/icons"));

        foreach ($files as $v) {

//            /var/www/html/uranaibako.com/public/img/icons/123164647.jpg
            $res = $v->getRealPath();

            //123164647.jpg
            $res = $v->getFilename();

        }

こんな感じ。

img/icons の中身を取得。
そして、パスを取得する場合は getRealPath とかを使う必要がある。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0