andrew.zahra wrote:
Is there any way to track completion of a download with PHP? I would
like to be able to check if a download completed successfully.
Yes, there is -- if the downloaded file has been served through PHP. That
is:
<?php
// This file is "myvid.php" .
session_start() ;
$_SESSION['download_attem pts'][] = 'myvid';
header("Content-Type: video/mpeg");
print file_get_conten ts("myvid.mpeg" );
if (!connection_ab orted())
$_SESSION['download_succe sses'][] = 'myvid';
?>
Now to link to the video, use:
<a href="myvid.php " type="video/mpeg">myvid</a>
And to check to see download status:
<?php
session_start() ;
if (in_array('myvi d', $_SESSION['download_attem pts']))
{
if (in_array('myvi d', $_SESSION['download_succe sses']))
{
echo 'User fully downloaded myvid';
}
else
{
echo 'User partially downloaded myvid';
}
}
else
{
echo 'User has not attempted to download myvid';
}
?>
That should work, though web proxies may complicate matters. (e.g. web
proxy downloads whole file, but only transmits part of it to client.)
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~
http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!