title: write a file and send it to user
body: <p>trying to write html to file and open a file dialog box</p>
  
  <p>for the user to save it </p>
  
  <p>but nothing happen and there is no errors</p>
  
  <p>any ideas ?</p>
  
  <p>thank you</p>
  
  <p>this is my code</p>
  
  <pre><code>&lt;?php
      $css=$_POST['css'];
      $html=$_POST['html'];
  
        $handle = fopen("file.txt", "w");
          fwrite($handle, $html);
          fclose($handle);
  
          header('Content-Description: File Transfer');
          header('Content-Type: application/octet-stream');
          header('Content-Disposition: attachment; filename='.basename($handle));
          header('Content-Transfer-Encoding: binary');
          header('Expires: 0');
          header('Cache-Control: must-revalidate');
          header('Pragma: public');
          header('Content-Length: ' . filesize($handle));
          ob_clean();
          flush();
          readfile($handle);
          exit;
  
      ?&gt;
  </code></pre>