I have a folder with huge amount pictures(10000 files at least) and I need to get names of all this files using PHP.
The problem is when I use scandir()
I got error about memory limit.
Also, I tried to use code like this:
$files = [];
$dir = opendir($this->path);
$i = 0;
while(($file = readdir($dir)) !== false) {
$files[] = $file;
$i++;
if ($i == 100)
break;
}
This code works fine, but it's not what I need. When I try to get all files, script still crashes.
Besides I thought about saving state of pointer in $dir
somehow for using it later through AJAX requests and getting all files, but I can't find any solution for that purpose.
Is there any method of set limit and offset for reading files? I mean like pagination.