By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,703 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,703 IT Pros & Developers. It's quick & easy.

Stop HTML output writing to file stream

code green
Expert 100+
P: 1,726
I am using the following to force a file dialog box to open
Expand|Select|Wrap|Line Numbers
  1. header('Content-Disposition: attachment; filename="'.$filename.'"');
  2. header('Content-type: text/csv');
Then open a file stream with
Expand|Select|Wrap|Line Numbers
  1. return $this->handle = fopen('php://output','w');
Which directs a file strean to output rather than write to a file.
Well that is how I understand it.
I then write the data then close the stream with
Expand|Select|Wrap|Line Numbers
  1. fclose($this->handle);
Problem is html output which I expect to display in the browser continues to write to the stream,
so HTML appears at the bottom of the CSV when opened.

What am I missing to close the file stream and output HTML?
May 10 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.