Hi,
I need something that lists the contents of files in a directory, and names each with a variable that I can use later for deleting/moving the file somewhere else.
Thank you.
Hi,
I need something that lists the contents of files in a directory, and names each with a variable that I can use later for deleting/moving the file somewhere else.
Thank you.
This should get you going.
<?php
$folder = "directory";
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
if (is_file("$folder/$file")) {
$size = filesize("$folder/$file");
echo "$file $size<br>\n";
}
}
closedir($handle);
}
?>
Thanks. It's perfect.
Sorry, but is there any way that this could be changed so it lists the contents of the files too?
echo file_get_contents("$folder/$file");
Ah ok. Thanks.