0
這是我的控制器功能,我使用數據庫實用程序庫爲數據庫備份備份。當我下載備份時,無法使用zip提取器打開zip文件。我該怎麼辦?Codeigniter數據庫備份不能返回可讀文件
function backup_database() {
$file_name = 'accounts';
$date = date('@Y.m.d-H.ia');
$name = $file_name . $date;
// Load the DB utility class
$this->load->dbutil();
// Backup entire database and assign it to a variable
$backup = & $this->dbutil->backup(array('filename' => "$name.sql"));
// Load the file helper and write the file to server
$this->load->helper('file');
write_file("$name.zip", $backup);
// Load the download helper and send the file to desktop
$this->load->helper('download');
force_download("$name.zip", $backup);
}
報價:_「你只需要到文件名添加到備份()數組,如果它是一個.zip文件」 _〜是不是那個什麼OP已經在做? – Sparky
不。他正在使用「$ name.sql」 – Craig