Page 1 of 1

Please help with header problem, parallel output

Posted: Thu Dec 11, 2008 9:31 pm
by flexy123
I cannot send header twice in a PHP file, and i also cant send a PHP header if there was already text output on the page.

So..how do i do it that i can eg. initiate a file-download, from a web-site or script?

(The file-download part is a little piece of 3rd party code which forces a download, it sets mine-types and HEADERS.
When the download initiates, the snippet send the headers and then prints the file)

Since this piece of code is ON a site/code where there already has been output...of course it comes up with
"cannot output since headers already sent"

Same problem eg with code which actually displays and streams a valid image with valid mime type and header.

I know there must be ways since web sites in PHP can very well display pictures. But if i build this code in another PHP i again have the problem i cant display the picture since the header is already sent by the content of the site!

there must be ways to have this output "parallel", and there must be ways to have eg a PHP program which can pop-up with a download window, sending content w/ valid headers from an existing site without telling me "headers already sent"..
Georg.

Re: Please help with header problem, parallel output

Posted: Thu Dec 11, 2008 10:47 pm
by requinix
Not quite sure what you're trying to do.

Just in case: you can't do an HTML page and an image at the same time.

Re: Please help with header problem, parallel output

Posted: Fri Dec 12, 2008 12:58 am
by anoopsn
Please try the following code,

<?php
ob_start();

// Add your page content here

ob_end_clean();
?>