Bluehost.com Web Hosting $6.95

downloading a file using headers

This is a discussion on downloading a file using headers within the PHP General forums, part of the PHP Programming Forums category; I have a page that queries the database then uses the data to build an excel spreasheet. THat spreadsheet is ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-30-2003
Amanda McComb
 
Posts: n/a
Default downloading a file using headers

I have a page that queries the database then uses the data to build an
excel spreasheet. THat spreadsheet is downloaded according to info in the
headers. My manager wants to put the page inside of another HTML page to
make it prettier, but then it breaks because headers are already written
(it's included in the other HTML page). It works fine on it's own, but
he really wants it in that page. He wants to know if there is a
way to trick it into working.

Any ideas? I can post the code if necessary, but it's loooong and messy.

THanks,
Amanda

Reply With Quote
  #2 (permalink)  
Old 07-30-2003
Cpt John W. Holmes
 
Posts: n/a
Default Re: [PHP] downloading a file using headers

> I have a page that queries the database then uses the data to build an
> excel spreasheet. THat spreadsheet is downloaded according to info in the
> headers. My manager wants to put the page inside of another HTML page to
> make it prettier, but then it breaks because headers are already written
> (it's included in the other HTML page). It works fine on it's own, but
> he really wants it in that page. He wants to know if there is a
> way to trick it into working.


Just set a flag on whether you send the headers or not. Have it default to
sending them...

if(!isset($somevariable))
{ header(...); }

---John Holmes...

Reply With Quote
  #3 (permalink)  
Old 07-30-2003
Curt Zirzow
 
Posts: n/a
Default Re: [PHP] downloading a file using headers

* Thus wrote Amanda McComb (amccomb@indiana.edu):
> I have a page that queries the database then uses the data to build an
> excel spreasheet. THat spreadsheet is downloaded according to info in the
> headers. My manager wants to put the page inside of another HTML page to
> make it prettier, but then it breaks because headers are already written
> (it's included in the other HTML page). It works fine on it's own, but
> he really wants it in that page. He wants to know if there is a
> way to trick it into working.


If I understand this corretly you want the page to be like:

[html stuff]
[excel spreadsheet]
[html stuff]

The only way to do this is using iframes or somthing similar to
that. You dont have to touch your php script at all.


Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Reply With Quote
  #4 (permalink)  
Old 07-31-2003
Jason Sheets
 
Posts: n/a
Default Re: [PHP] downloading a file using headers

You could use an iframe or you could turn on output buffering, when
output buffering is enabled you can send headers after normal output has
been sent. Just do ob_start(); at the top of your script. Not the most
elegant way of doing it but it would work and not require you to use an
iframe.

Jason

Amanda McComb wrote:

>I have a page that queries the database then uses the data to build an
>excel spreasheet. THat spreadsheet is downloaded according to info in the
>headers. My manager wants to put the page inside of another HTML page to
>make it prettier, but then it breaks because headers are already written
>(it's included in the other HTML page). It works fine on it's own, but
>he really wants it in that page. He wants to know if there is a
>way to trick it into working.
>
>Any ideas? I can post the code if necessary, but it's loooong and messy.
>
>THanks,
>Amanda
>
>
>
>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:05 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0