Get the names of all files from a folder, using PHP

You can do that by using the scandir php function:

scandir-php

A simple code:

$dir = ‘images’;
$extract = scandir($dir);

To show the results, use:

print_r($extract);

How to turn print_r($extract); into a variable?

Like this:

foreach($extract as $file)
{
}

and echo”.$file.”;

$file will be the variable.

After this, you can copy paste your results into an excel file and save the file as .csv.
You can import the .csv file into phpmyadmin.

test

If you have any questions, leave in the comments.

ADD A COMMENT: