I try to read the files from the folder, I write the following

<?php $dir="files"; $entries = scandir($dir,1); $filelist = array(); foreach($entries as $entry) { $filelist[] = $entry; } foreach ($filelist as $file) { echo $path=$dir."/".$file; $text = file_get_contents($path); } 

I get the Warning: file_get_contents (files / ..): I’ve got the local XAMPP server, I’ve looked at the files folder there, I’ve got access to it

  • It is worth replacing / with DIRECTORY_SEPARATOR and checking the file for the presence of the function file_exists - Naumov

1 answer 1

Replace

 $entries = scandir($dir,1); 

on

 $entries = array_diff(scandir($dir, 1), array('..', '.'));