Logging a file download

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
netplay
Forum Newbie
Posts: 6
Joined: Mon May 19, 2008 4:45 am

Logging a file download

Post by netplay »

Hi All,
I need a little help from you guys for a file download. I need to let my site users download a document file.
A user is provided with a link to download the file. However every time a user downloads a file, I need to log his IP address to a database. How can this be achieved seamlessly with any page refreshes etc. After logging the IP, can I change the file header to doc and populate the file with the contents with my document file ? What program construct do I need to use to copy the content from the original document file to the dynamically created file ? I would be very grateful for any information or pointer to an online article.

Thanks,
- Alec
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Logging a file download

Post by Jade »

It seems to me the easiest thing to do would be to log their IP once they click some kind of link (ie use some javascript or ajax). Otherwise you could setup a .php file that loads the document they're trying to download but adds the file they're downloading and their IP to your database table first.
Post Reply