473,830 Members | 2,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tracking download completion

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.

My first thought is that I might need to use an applet?

Any suggestions appreciated.

Feb 15 '07 #1
2 1825
On Wed, 14 Feb 2007 23:19:01 -0800, 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.

My first thought is that I might need to use an applet?

Any suggestions appreciated.
According to the PHP manual, scripts are aborted if the client
disconnects. Therefore assuming you're using a PHP script to download the
file if it gets to the line after readfile() (or some such code) then the
client connection is still active and therefore the download completed.

However, you can turn this functionality off so the script always
completes whether the client disconnects or not. So it may be best to use
connection_abor ted() to see if the client is still connected.

You can read more about it here:

http://uk.php.net/manual/en/features...n-handling.php

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE CMDEV
Zend Certified Engineer
Certified MySQL Developer
gPHPEdit Lead Developer - http://www.gphpedit.org

Feb 15 '07 #2
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!
Feb 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1252
by: David Barrett | last post by:
I'm proud to announce the completion of QwikiWiki v1.4.1, available for download now! QwikiWiki has the fastest installation, easiest syntax, and the fewest, highest-value features of any wiki around. Not only that, QwikiWiki is open source, requires no prior wiki experience, no advanced Unix skills, and never needs a database! If you're new to wikis and looking for a place to start, QwikiWiki's emphasis on simplicity and...
2
1587
by: Steve Lloyd | last post by:
Hi, I am trying to create a popup progress box for a downloading file and then do a page redirect/transfer on completion of the download and also to confirm completion of the download, much like downloads on the microsoft site. The download is protected by using a naming it as an aspx file and then streamed to the user using the reponse object Response.AddHeader("Content-Disposition", "attachment; filename=" & Replace(myFile.Name,...
5
1589
by: Mickey | last post by:
Hi all, Is there a way to find out when a user has completed a download? I ask this because I have a current system where users download files, however due to serious bandwidth issues I need to limit the amount of downloads at one time. Ideally, I want to be able to allow a maximum of 5 members to access the download page at one time (with one download per person at one
2
23935
by: Dan D | last post by:
I have a large install file (an exe) on my web server that people download and install from. Looking at my log files, I see a lot of people downloading it, but no way to tell for sure if they completed the download or cancelled out before it completed. Is there any function in PHP that would allow the web server to send the file and detect a completion or cancellation? Or perpahs a javascript/PHP method? Any help would be greatly...
5
4895
by: Dan D | last post by:
I have a large install file (an exe) on my web Apache server that people download and install from. Looking at my log files, I see a lot of people downloading it, but no way to tell for sure if they completed the download or cancelled out before it completed. Are there any known methods that would allow the web server to send the file and detect a completion or cancellation? Or perhaps a javascript method or html request trick that would...
4
1643
by: moogyd | last post by:
Hi, (Off-topic) I am looking to put an open-source bug/issue tracking system in place for our current project (eventually expanded for all projects), and would appreciate any experiences/comments/suggestions. Note the project is encompasses embedded hardware (ASIC plus firmware) plus application software.
2
1726
by: C# programmer | last post by:
Hi All, I'm working on a project which requires tracking of recent document downloads. There is a feature in which user can download the docs without logining into the website for some of the clients. While for other clients user has to log into the website to download docs. We used to create dummy/fake accounts(in sql server) for client users who do not require login and use the created account to track recent downloads(using cookie...
6
3433
by: rahul sinha | last post by:
Please help me to find a email class which contains the functions for sending email as well as email tracking. Thanks Rahul S
2
1010
by: Santel | last post by:
Hi, To provide download functionality, I used the below code. Response.ContentType = "application/x-download"; string strFileName=@"d:\Landscape.jpg"; Response.AddHeader("Content-Disposition", "attachment; filename=testing.jpeg" ); Response.WriteFile(strFileName); Response.End();
0
9790
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10481
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10199
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6948
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5779
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4409
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3956
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.