I want to back up a flat field database - by clicking a button on a web page and the entire directory then emailed to me. I can manage to do this for a single file but am stumped to get an entire directory contents sent at once. This is the code I have been using but I get an error - and an emtpty email! Help appreciated. Thanks.
<?php
$path = "/directory/to/the/files/";
$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle)) {
if(!is_dir($file)) {
$fp = fopen($file,"r");
$msg = fread($fp,filesize($file));
fclose($fp);
}
}
mail($owner, "DB ", $msg ,"From:$owner");
closedir($dir_handle);
?>