I don't know which language you need it in, but here is how I would do it using PHP and MySQL:
With PHP and MySQL:
PHP Code:
<?php
$file_list=scandir($dirname);//returns an array containing names of all file and folders.
foreach($file_list as $file)
{
$sql="";//your SQL command
mysql_query($sql);
}
?>
The target folder may contain more folders too. If you want to exclude those folder names from being added to the database, use the is_file() function. It returns false of it is a folder. So put a conditional statement that will insert the file name only if is_file() function returns true.
Doing it without MySQL:
PHP Code:
<?php
$file_list=scandir($dirname);
foreach($file_list as $file)
{
echo "<li>".$file."<li>";
}
?>
Note: scandir() function is available from PHP 5. PHP 4 does not have such a function.