Skip to content Skip to sidebar Skip to footer

How To Tell If A File Was Really Downloaded And Saved, Despite Browser Prefetch/cache?

I am creating a script to keep download statistics, but I would only like to update the stats if the file was ACTUALLY downloaded. The problem is that browsers (e.g., Explorer 9, C

Solution 1:

You can't do what you are wanting to do. It is impossible, at least in the way you are asking.

What you can do is put some code in the installer that reaches out to your server when it runs, and your script can keep track of it then. This is commonly done, but is certainly not foolproof. Many people download software and install offline. (Particularly, dial-up users, which are still out there by the thousands.) Also, there is no guarantee that the installer won't be blocked by firewall software or something.

So this all depends on how bad you need to know when it was installed. If it is critical, then your installer needs to verify with the server before installing. Of course this can be hacked around, and there is nothing you can do about it. But, I suspect it will work for your purposes.

Also, don't forget about multiple installs per download.

Solution 2:

I don't think you can see this. You'll have to let someone pay for the software before sending it to the client.

And I suggest you let the site remember the purchase, so if something went wrong during the download, a user can retry, without having to pay again (or contacting an administrator).

Solution 3:

Well, having some sort of intermediate page to confirm "yes I want to download this" may mostly eliminate canceled downloads.

Now, I'm not sure this is entirely possible, but you may try to serve the file via PHP, instead of the typical download from Apache. In PHP, you can use readfile to serve a file from the PHP script. So, you may be able to call readfile, flush, and determine the number of bytes served. If that doesn't equal the number of bytes in the file, it was interrupted. I'm not sure if readfile works like that, but its worth experimenting with.

Note, that still won't fix what Marcel mentioned, about hitting 'Cancel' before the tempfile download completes.

Post a Comment for "How To Tell If A File Was Really Downloaded And Saved, Despite Browser Prefetch/cache?"