send group of files at once to website administrator
| From: | anders thoresson | Date: | Sun, 10 Aug 2003 17:58:38 +0000 |
| Subject: | send group of files at once to website administrator | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-159042@lists.php.net to get a copy of this message | ||
Hi,
I have the following code which I use to make regular backups of my databases. Is there a way to have all backup files sent at once after they are created, istead of presenting the list of files available for download?
db_connect($dbuser, $dbpassword, $dbdatabase);
// Lock and flush tables before backup
$query = "LOCK TABLES un_article READ, un_article_writer READ";
$result = mysql_query($query)
or error(mysql_error());
$query = "FLUSH TABLES";
$result = mysql_query($query)
or error(mysql_error());
// Perform backup
$query = "BACKUP TABLE un_article, un_article_writer TO 'c:/web/un/backup'";
$result = mysql_query($query)
or error(mysql_error());
// Unlock tables
$query = "UNLOCK TABLES";
$result = mysql_query($query)
or error(mysql_error());
// Present all files with link to download
if ($handle = opendir('/web/un/backup')) {
echo "Files:<br>\n";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) { echo "Download $file <a href='backup/$file'>here</a><br>\n";
}
closedir($handle); }
--
anders thoresson