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 #186402 is a reply to message #186400] Sat, 19 July 2014 15:38 Go to previous messageGo to previous message
Lew Pitcher is currently offline  Lew Pitcher
Messages: 60
Registered: April 2013
Karma:
Member
Thanks for the response, Thomas.

Next time, please contain your snark. It ill suits you.

On Friday 18 July 2014 11:39, in comp.lang.php, "Thomas 'PointedEars' Lahn"
<PointedEars(at)web(dot)de> wrote:

> Lew Pitcher 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.
>>
>> The user selects (in this case) "Export recipes" (I'm developing a
>> PHP/MySQL recipe management application), which causes
>> 1) the page to change to a "Download in progress" page, and
>> 2) a file (in this case, an XML file containing the recipes) to be sent
>> to the client.
>>
>> Is this doable?
>
> Yes. There are plenty of productive examples on the Web, for example when
> you download from sourceforge.net and use the additional download link
> (client-side scripting will trigger the download dialog automatically, but
> you can cancel that)

I can, by viewing the source of web pages that use multiple javascript files
with intentionally convoluted logic, and filtering out (in a masterly way)
all that extraneous stuff, find that the web page in question (such as the
download page for a sourceforge project) does *not* include the "server
side" logic that does this. I can /then/ examine the headers from such a
working page, *deduce* that the page sent both html
and "Content-Disposition" (etc.) headers, and *assume* the method of
generating such.

Indeed, this is how I've done it in the past, with poor results.


>> How do I do this with PHP?
>
> There are several ways. Another is:

And, the first was?

>
> <?php
> header('Content-Disposition: attachment; filename="foo.bar"'); …
> header('Location: http://download.example/foo.bar');
> ?>
>
> displayed content
>
> This not just a (PHP) language feature, it is using a language-independent
> HTTP feature.

But, to set headers, you need some sort of active language. Mine is PHP..

> You can use browser developer tools to inspect the HTTP
> response headers, then use the corresponding PHP functions to achieve the
> same.

Or, I can ask in a forum that specializes in such programming, and save
myself the blind alleys, false starts, and mis-assumptions that such an
inspection of the outside effects would bring

[snip suggested tools]


>
> Next time, do your homework, please.

Condescending, no?

In fact, I've done my homework. And *this* is part of that homework.

Thomas, either be helpful or don't reply. Such snark is not helpful.
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
[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: Fri May 10 07:03:09 GMT 2024

Total time taken to generate the page: 0.04785 seconds