Entry
How do I track file downloads for storage in a database?
How do I get information from Apache?
How can I send files to the client?
Feb 18th, 2000 09:13
Matt Gregory, Matt Herbert, Dax Mickelson, unknown unknown,
There are many ways to approach this problem but all require that you
return the file through a script (Obviously since you must call PHP to
put the information in the database).
The approach I find most appealing is this:
(Called something like this--> http://mysite/getfile.php3?fileid=0001)
Get the id of the file they are wanting to download and look it up in
your database. Send a header to the client with the file's mime type
and then pump the file using the fopen/fread functions.
Then just use date functions to get the date, you already have the
filesize and filename. You can get the time before the download starts
to figure out how long it took to send it (approximate). As far as user
information: require that everyone downloading a file provide a
username and email (or even a password) either at download time or when
they enter your site (via user-entry or cookie).
You can also get information on the request from Apache using the
Apache specific getallheaders()
(http://www.php.net/manual/html/function.getallheaders.html) function.
There is probably a way to get information on the user cancelling the
download from Apache, but I am not familiar with Apache. If someone
else knows how to do this, please input.