0

This question already has an answer here:

I tried to implement a custom download link in the theme settings, section that will give the users to download there custom settings for the backup. I tried this option

if( isset($_GET['download']) && $_GET['download'] == true ) {

            $data = '';

            if( $upanel !== FALSE ) {
                $data .= serialize(
                        array(
                            'theme'=>'theme_name', 
                            'data'=>$upanel
                        )
                );
            }


            $filename = "theme_settings.txt";


            header("Content-Disposition: attachment; filename=".$filename);
            header("Content-Type: application/download");
            header("Pragma: no-cache");
            header("Expires: 0");

            echo $data;
            exit();
        }

This section working fine and the data is downloaded correctly but its also insert the header html code into the text file. Like all the HTML codes.

Its clue less for me, that without inserting in my text file, hows it comes there? How do i rid from the header html codes.

Downloaded sample:

</div>
            </div>
// Above is unexpected html code from starting
// into the theme_settings.txt file
//Data that i want only
 a:2:s:5:"theme";s:6:"theme_name";s:4:"data";a:52:s:9:"site_logo";s:0:"";s:12:"site_favicon";s:0:"";s:1

marked as duplicate by fuxia Sep 8 '14 at 7:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Now it is solved, what i have done is, just hook my download script to admin_init hook and its working that i want.

This is the helpful link Headers already sent error with CSV export plugin

Not the answer you're looking for? Browse other questions tagged or ask your own question.