Re: Generating "download" pages [message #186408 is a reply to message #186400] |
Sat, 19 July 2014 17:43 |
Christoph Michael Bec
Messages: 207 Registered: June 2013
Karma:
|
Senior Member |
|
|
Thomas 'PointedEars' Lahn wrote:
>> On response to a trigger on one web page, I want to be able to generate
>> and display a new web page, /and/ at the same time, send an associated
>> file as a download.
>>
>> How do I do this with PHP?
>
> There are several ways. Another is:
>
> <?php
> header('Content-Disposition: attachment; filename="foo.bar"'); …
> header('Location: http://download.example/foo.bar');
> ?>
>
> displayed content
How is that supposed to work? HTTP can only deliver a single response,
and AFAIK there is no such thing as multipart responses for HTTP.
Anyway, I have tried that idea, and that confirmed my presumption that
the browser is redirected to the Location URI, but the "displayed
content" is not shown.
Using a Refresh header instead of Location might work, but on one hand
the Refresh is not part of the HTTP/1.1 specification (CMIIW), and on
the other the effect is not exactly what the OP asked for. It seems to
me the only way to get this behavior would be in combination with client
side scripting, what would be on-topic for comp.lang.javascript, for
instance.
--
Christoph M. Becker
|
|
|