PHP多个ob_start()和ob_end_clean()函数不起作用

时间:2014-12-05 21:51:03

标签: php ob-start

我有这个索引页面:

<?PHP
ob_start();
session_name('D12TYU');
@session_start();
ob_end_clean();
require ABSPATH .'/config.php';
require ABSPATH . '/class/backup.php';
?>
<!DOCTYPE html>
<html>
....... html+<?PHP ?> Code
</html>

在备份类中我有下载备份文件的代码:

    class DB_Backup
    {
    //OTHER CODE

    public function download($file)
    {
    ob_start();
    $filename = $this->dir . $file;
    $fp = fopen($filename, "rb");
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-type: application/octet-stream");
    header("Content-length: " . filesize($filename));
    header("Content-disposition: attachment;filename = " . $file . "");
    ob_end_clean();
    die(fpassthru($fp));
    fclose($fp);
    }

    //OTHER CODE
    }

现在,当点击链接(?action=options&mod=backup&do=download&id=db-backup.zip)获取下载文件时,我会看到:

enter image description here

我无法下载我的备份文件。我认为我的问题是ob_start();ob_end_clean();。我怎么能解决我的问题?!​​

0 个答案:

没有答案