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 #186403 is a reply to message #186400] Sat, 19 July 2014 15:58 Go to previous messageGo to previous message
Lew Pitcher is currently offline  Lew Pitcher
Messages: 60
Registered: April 2013
Karma:
Member
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.
>>
[snip]
>> 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
[snip]

Now, having tried your suggested solution, I must tell you that *it did not
work*. So much for /your/ advice.

Here's the PHP I wrote:
<?php
header('Content-Disposition: attachment; filename="SixSpot_d.png');
header('Location: http://merlin.puter.lan/~lpitcher/SixSpot_d.png');
?>
<html>
<head><title>Trial Sendfile</title></head>
<body>
<p>Did you get it?</p>
</body>
</html>

There exists, in the source directory, a PNG file named "SixSpot_d.png.
That file can be accessed through the (internal) url
http://merlin.puter.lan/~lpitcher/SixSpot_d.png'

The web page, above, fails to initiate a download or show the specified web
page.

Instead, the web browser (Firefox 5.0.1 for Linux) /displays/ the specified
PNG, instead of the specified html, and /does not/ initiate either an
automatic download into the configured download directory or the Download
menu itself.

Advice (from various sources including PHP.NET) conflict as to which headers
are required, and the order of steps to perform.

So, Thomas, got any more "advice" for me?
--
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 19:49:09 GMT 2024

Total time taken to generate the page: 0.06460 seconds