I generally find glob() easier to use, as one function call will create an array of file path-names. If all you want are the file names, you can do a chdir to that directory first:
$dir = "path/to/directory";
$curdir = getcwd();
chdir($dir) or die("Invalid directory");
$files = glob('*'); // might want to filter out "." and ".." if applicable
chdir($dir); // back to original directory
$values = array();
foreach($files as $file) {
$values[] = "('" . mysql_real_escape_string($file) . "')";
}
$sql = "INSERT INTO table_name (file_name) VALUES\n" . implode(",\n", $values);
$result = mysql_query($sql);
(untested, of course 😉 )