Page 1 of 1

Using Headers For Download System

Posted: Thu Jun 16, 2005 4:01 pm
by Nelsobra
I'm trying to use headers to point the browser to a file download, but I run into the headers already sent error. To rectify this I tried using output buffering, but when I tried this the file would download but would contain an extra 1.6kb of data and would be corrupt(the 1.6kb extra is the size of my style.css file)
To give some background, I have an index.php file which includes my downloads.php file.

Any insight would be appreciated

Posted: Thu Jun 16, 2005 4:03 pm
by hawleyjr
If anything (css,spaced,text) is printed to the browser before the header call. The header() function will throw an error.

Posted: Thu Jun 16, 2005 4:04 pm
by Nelsobra
I realise that and that's why i've tried to use output buffering, but I still can't manage to get it to work. I believe it might have something to do with the fact that the index file starts output while the downloads.php file is trying to send headers. Whatever the reason is I can't get output buffering to work.

Posted: Thu Jun 16, 2005 7:03 pm
by timvw
At first sight your index.php shouldn't "include" but "link to" download.php