I am trying to get content of all the files in my directory and I am getting an error that says
ErrorException in Util.php line 114: preg_match() expects parameter 2 to be string, array given
. Below is the code that I am using.
public function store(Request $request)
{
$directory = storage_path('app/xmlentries/uploads');
$files = File::files($directory);
foreach ($files as $file)
{
$contents = Storage::get($file);
dd($contents);
}
How would i get the contents of all my files in this folder?
Try this:
$directory = storage_path('app/xmlentries/uploads/');
foreach (glob($directory . "*") as $file) {
$fileContent = file_get_contents($file);
dd($fileContent); // change this per your need
}
Please note this will display the first file and then stop!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.