Why does my file being downloaded have my page's HTML appended?
<h3>Update:</h3>

<p>Never mind. It was happening because it was adding the headers back. So I moved the php code separate from html and it worked. thanks guys</p>

<p>I am using the code below </p>

<pre><code> &lt;?php 

        $target_path = "Files/";
        $target_path = $target_path . basename( $_FILES['decryptfile']['name']);


                    $fp = fopen('Files/'.$_FILES['file']['name'], 'rb');
            header('Content-type: '.$_FILES['file']["type"]);                                                              
            header('Content-Disposition: attachment; filename="'.$_FILES['file']['name'].'"'); 
            header("Content-Length: " . filesize('decryptedFiles/'.$_FILES['file']['name']));


            fpassthru($fp);
            exit;
            die();





    ?&gt;



    &lt;form enctype="multipart/form-data" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST"&gt;
    Choose a file : &lt;input name="file" type="file" /&gt;&lt;br /&gt;&lt;p&gt;
    Start  process&lt;/a&gt;&lt;/center&gt;&lt;/p&gt;
    &lt;p&gt;&lt;center&gt;&lt;input type="submit" value="File" /&gt;&lt;/center&gt;&lt;/p&gt;

    &lt;/form&gt;
</code></pre>

<p>My file contents are:</p>

<p>1234567890</p>

<p>when I download the file it shows</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;

&lt;/head&gt;

    &lt;form enctype="multipart/form-data" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST"&gt;
    Choose a file : &lt;input name="file" type="file" /&gt;&lt;br /&gt;&lt;p&gt;
    Start  process&lt;/a&gt;&lt;/center&gt;&lt;/p&gt;
    &lt;p&gt;&lt;center&gt;&lt;input type="submit" value="File" /&gt;&lt;/center&gt;&lt;/p&gt;

    &lt;/form&gt;


1234567890
</code></pre>

<p>Problem is that it appends (includes) the html of my web page to the file... how can I avoid that. thanks</p>
