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 #186420 is a reply to message #186416] Sat, 19 July 2014 21:00 Go to previous messageGo to previous message
Lew Pitcher is currently offline  Lew Pitcher
Messages: 60
Registered: April 2013
Karma:
Member
On Saturday 19 July 2014 16:54, in comp.lang.php, "Lew Pitcher"
<lew(dot)pitcher(at)digitalfreehold(dot)ca> wrote:

[snip]

> However, I have found a workaround that will suffice until I determine the
> proper way to get both updated page /and/ download:
>
> The request page (that which I want to update and redisplay) will contain
> within it an (almost) invisible <iframe> linking to a /second/ page. That
> second page will /only/ generate the file transfer headers and file.
>
> Together, the two pages will do what I had hoped to do in one page.
>
> Thanks to all for all the advice.

The main page (sendfile_2.php) looks like this....

<?php
session_start();
$showfile = false;

switch ($_SERVER['REQUEST_METHOD'])
{
case 'GET':
$count = 0;
break;

case 'POST':
$count = 1 + $_SESSION['Count'];
$showfile = (isset($_POST['Action']) && $_POST['Action'] == 'Send');
break;
}
?>
<html>
<head><title>Trial Sendfile</title></head>
<body>
<h1><?php print $count ?></h1>
<p>Did you get it?</p>
<form method="post">
<input type="submit" name="Action" value="Send"/>
</form>
<?php
if ($showfile)
{
?><iframe src="sendfile_2a.php" width="0" height="0" border="0"
frameborder="0" /><?php
}
?>
</body>
</html>
<?php
$_SESSION['Count'] = $count;
?>


The "download helper" page (referenced in the iframe and
called "sendfile_2a.php here) looks like this...

<?php
$file="./SixSpot_d.png";

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize ($file));
readfile($file);
exit(0);
?>


--
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: Thu Nov 21 19:53:47 GMT 2024

Total time taken to generate the page: 0.04023 seconds