You are here: Re: Tracking download completion « PHP Programming Language « IT news, forums, messages
Re: Tracking download completion

Posted by Toby A Inkster on 02/15/07 10:06

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_attempts'][] = 'myvid';

header("Content-Type: video/mpeg");
print file_get_contents("myvid.mpeg");

if (!connection_aborted())
$_SESSION['download_successes'][] = '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('myvid', $_SESSION['download_attempts']))
{
if (in_array('myvid', $_SESSION['download_successes']))
{
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!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация