RE: [PHP] File Download Completion
| From: | Boaz Yahav | Date: | Wed, 31 Jan 2001 20:00:34 +0000 |
| Subject: | RE: [PHP] File Download Completion | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-37528@lists.php.net to get a copy of this message | ||
Seems like your theory doesn't stand the reality test :)
This is the script which for some reason works with Netscape but not with IE
(it used to) :
ignore_user_abort(0);
$filename="test.gz";
$file="/home/examples/" . $filename;
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/x-gzip");
header("Content-Length: ".filesize($file));
header("Pragma: no-cache");
header("Expires: 0");
$fp = fopen($file, "r");
if(!$fp) {
echo"Can't open file for read";
exit();
}
print fread($fp, filesize($file));
echo"<BR><BR><BR><BR><H1><B>The file was downloaded
successfully</B></H1><BR><BR><BR><BR>";
For some reason it never shows the last echo weather i let the DL complete
or stop it
in the middle...
berber
-----Original Message-----
From: Daniel Grace [mailto:dewin@oldbattery.com]
Sent: Wednesday, January 31, 2001 2:37 PM
To: php-general@lists.php.net
Subject: Re: [PHP] File Download Completion
"Boaz Yahav" <berber@netvision.net.il> wrote in message
news:EEC6EBAB1A35E94789FB2872A1698F75145164@ntx2.netvision.net.il...
> Is it possible to find out if a client finished to DL a file?
>
> Suppose i put a link to a file and people start to DL the file.
> Some people can stop the DL in the middle. I need to know
> how many people completed the DL.
>
> Any simple ideas how to do this?
>
> thanks
>
> berber
>
One option could be to use ignore_user_abort:
<?PHP
ignore_user_abort(0); // Script will be aborted if transfer fails for
whatever reason
?>
blahblahblahyaddityyaddiy yaddity
<?PHP
// If we're this far, it means the file's more or less transferred all the
way.
file_did_download();
?>
Caveats with this:
1. Your file has to be part of the PHP page (though not neccessarily in the
file itself, header("content-type: blah/blah"); combined with
readfile($filename) will do the trick I think.
2. You (probably) can't use programs that are capable of resuming file
transfers. If you can somehow, I have NO idea how it'll react.
3. If the user aborts right after the file_did_download() function is called
but before the script actually terminates, things can go awry. I'm not
entirely sure how this would be handled.
--
- Daniel Grace <http://dewin.oldbattery.com/>
"Space may be the final frontier but its made in a Hollywood basement."
- Red Hot Chili Peppers - Californication
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net