header function query

header function query

am 26.02.2010 07:49:51 von Nick Allan

------=_NextPart_000_0087_01CAB70C.1B0C4540
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

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




------=_NextPart_000_0087_01CAB70C.1B0C4540--

Re: header function query

am 26.02.2010 10:31:05 von Richard Quadling

On 26 February 2010 06:49, Nick allan wrote:
> Hi all
>
> The situation is as follows
>
> I've read some data in from a couple of files into a string variable, mad=
e
> 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-Di=
sposition: attachment;
> filename=3D"preq.doc"');
>
> ob_clean();
>
> echo $allText;
>
>
>
>
>
> The above code works fine, the client gets a file download dialogue and c=
an
> save or open the file.
>
> How can I indicate end of file, then continue writing html to display a n=
ew
> page. I want to be able to ask the user some additional questions after t=
hey
> 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 tag, a
redirect tag to the URL just for the download file.




--=20
-----
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=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: header function query

am 26.02.2010 12:32:21 von Rene Veerman

output the html you want to send afterwards first,

then either put a link to another script that outputs the word file,
or have an auto-launch ajax routine (i recommend jquery.com for ajax)
do it automatically.

On Fri, Feb 26, 2010 at 7:49 AM, Nick allan wrote:
> Hi all
>
> The situation is as follows
>
> I've read some data in from a couple of files into a string variable, mad=
e
> 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');
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0header('Content-Disposition: attachment;
> filename=3D"preq.doc"');
>
> ob_clean();
>
> echo $allText;
>
>
>
>
>
> The above code works fine, the client gets a file download dialogue and c=
an
> save or open the file.
>
> How can I indicate end of file, then continue writing html to display a n=
ew
> page. I want to be able to ask the user some additional questions after t=
hey
> have downloaded the file. =A0My problem is that if I add any html code af=
ter
> 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
>
>
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php