Re: header function query
| From: | Richard Quadling | Date: | Fri, 26 Feb 2010 09:31:05 +0000 |
| Subject: | Re: header function query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302399@lists.php.net to get a copy of this message | ||
On 26 February 2010 06:49, Nick allan <nallan@wdev.net> wrote:
> Hi all
>
> The situation is as follows
>
> I've read some data in from a couple of files into a string variable, made
> some changes to it and want to send the contents of the string out to the
> browser as a word document.
>
> My code currently looks like the following
>
> header('Content-Type: application/msword');
>
> header('Content-Disposition: attachment;
> filename="preq.doc"');
>
> ob_clean();
>
> echo $allText;
>
>
>
>
>
> The above code works fine, the client gets a file download dialogue and can
> save or open the file.
>
> How can I indicate end of file, then continue writing html to display a new
> page. I want to be able to ask the user some additional questions after they
> have downloaded the file. My problem is that if I add any html code after
> the above echo statement, it is included in the downloaded file.
>
> There's probably a simple answer to this, but I haven't been able to find
> anything using google.
>
>
>
> Thanks in advance for any suggestions.
>
>
>
> Regards Nick
>
>
>
>
Under normal conditions, you can't.
A request is for a single thing. While it is potentially possible to
embed graphics, css, js into a single html file request, downloading
files is not.
Instead, you issue the html first, but include in the <head> tag, a
<meta> redirect tag to the URL just for the download file.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling