PHP multiple ob_start() and ob_end_clean() function not work

829 Views Asked by At

I have this index page :

<?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>

in backup class i have this code for download backup file :

    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
    }

now, when click in link(?action=options&mod=backup&do=download&id=db-backup.zip) for download file i see this:

enter image description here

i cant download my backup files. i think my problem is ob_start(); and ob_end_clean();. how do can i fix my problem ?!

0

There are 0 best solutions below