FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Generating "download" pages
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Generating "download" pages [message #186422 is a reply to message #186408] Sat, 19 July 2014 23:04 Go to previous messageGo to previous message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma:
Senior Member
Christoph M. Becker, 2014-07-19 19:43:

> 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.

It will not work - the browser will likely follow the Location header
and just ignore the Content-Disposition.

> 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.

Yep - it's right, a Refresh header is not part of HTTP/1.1 - but most
browsers will still accept it (at least when using <meta
http-equiv="refresh" ...>) and behave as expected. As a fall back one
should offer a direct link within the displayed content anyway - since
client side scripting may also not work if the user did not enable it.



--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Resolved: Generating "download" pages
Next Topic: Your opinion on which technologies to use when building web applications
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu May 09 20:10:05 GMT 2024

Total time taken to generate the page: 0.05512 seconds