当前正在尝试播放文件,但努力弄清楚将文件放置在哪里以及如何将它们读回到列表中.
香港专业教育学院试图把一些测试文件
$files = array();
$dir = opendir(asset('files'); // open the cwd..also do an err check.
while(false != ($file = readdir($dir))) {
if(($file != ".") and ($file != "..") and ($file != "index.php")) {
$files[] = $file; // put in array.
}
}
但尽管其中包含3个测试文件,但它只是返回空白.
调查幼虫的食谱和建议说File:allFile()这不是受支持的方法,但它让我想知道除了如何从目录读取文件之外,我应该在哪里真正将要存储的文件存储在服务器上.
解决方法:
Laravel 5.3使用Storage instead of Files.您可以使用以下两种方法之一访问目录中的所有文件:
use Illuminate\Support\Facades\Storage;
$files = Storage::files($directory);
$files = Storage::allFiles($directory); // Includes subdirectories
标签:laravel-5,file,storage,php
来源: https://codeday.me/bug/20191026/1935203.html