[kdewebdev-webdeveloper] download cgi
Eric Laffoon
eric at kdewebdev.org
Tue May 18 15:52:21 EDT 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 17 May 2004 8:06 pm, Tami King wrote:
> Hopefully this isn't too off topic for this list. I need to
> write a small CGI that will download a file. I have the download
> part working and I was wondering if there was some way to display
> new content in the browser or run another CGI after the download
> is finished?
This is totally on topic
The paradox is that if you display information from what is done server side
it will not write until complete. The solution is not all that easy using
Javascript. You can also redirect with headers but this will fail if you've
already sent something to the browser. A third option is to have the CGI
create a button, which will be displayed at the completion of the script,
that is in a form pointing to the page you want to display or more scripting.
An example...
<?PHP
// process response
if ($_POST['pageview'] == 1) {
// processing goes here
}
include ("header.inc")
if (!$_POST['pageview']) {
?>
<!-- first time here - initial form goes here - include below in form -->
<form action="<? echo $PHP_SELF ?>" method="post">
<input type="hidden" name="pageview" value="1">
<?PHP
} else if ($_POST['pageview'] == 1) {
?>
<!-- second time here - form goes here - include below in form -->
<input type="hidden" name="pageview" value="2">
Operation complete. Click to do next...
<?PHP
} else if ($_POST['pageview'] == 2) {
?>
<!-- second time here - optional but you could process based on previous
message or redirect -->
Operation complete message
<?PHP
}
include ("footer.inc");
?>
- --
Eric Laffoon - Quanta+ Team Leader
http://kdewebdev.org eric at kdewebdev.org
Mailing list - http://mail.kde.org/mailman/listinfo/quanta
GPG Fingerprint: 48FB 218D 747F A54A 319D EE98 4A25 794E A453 004B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFAqoWVSiV5TqRTAEsRAlRpAKCJ5LKrTC++ypbs5gwHvV81sTwyuQCeJAOL
1SP+i+RlOZ7ZdsA6No7xtQE=
=OCX5
-----END PGP SIGNATURE-----
More information about the kdewebdev-webdeveloper
mailing list