Topic awaiting preservation: Next Step: Log the Downloads (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 05-05-2005 01:39
Okay, so now that my nifty PHP image-downloading script is working, I've decided I'd like to know when the clients are actually downloading the images. I figure writing to a simple text file that X file was downloaded will do just fine. I believe I can handle that part, but I'm not sure how I should trigger it. |
Maniac (V) Inmate From: under the bed |
posted 05-05-2005 01:45
I would personally use a redirect. |
Maniac (V) Mad Scientist From: Belgrade, Serbia |
posted 05-05-2005 10:16
Don't forget to use some sort of file locking ( php->flock() ) while writing to the text file, if you don't want to end up with corrupted content in case of parallel writes. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 05-06-2005 18:33
That's what I had originally considered, actually -- going to another page and redirecting. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 05-06-2005 18:59
That's how I'd do it. code: <a href="index.php?download_file=/path/to/file.zip&invoicenumber=XXXX" />
|
Maniac (V) Inmate From: under the bed |
posted 05-06-2005 23:20
what I posted originally can also be done by simply reloading the same page with the link, as BD stated. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 05-09-2005 03:32
IMHO I would always use a database if possible for data storage. If you are getting thousands of requests an hour you might need a more scaling solution. There is also the possability of just parsing your log files. Might not offer the control you are looking for though. code: <?php
|
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 05-09-2005 18:58
I had thought about linking the page to itself like that originally, but I wasn't sure if the page would reload reliably. I might go ahead and do it that way. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 05-09-2005 19:40
You will find that using a database tends to be the easy solution, and ultimately less complicated. That is why I reccomend it. code: CREATE TABLE imagetracker (image VARCHAR(255), hits INT)
code: <?php
code: <?php
|
Maniac (V) Inmate From: under the bed |
posted 05-10-2005 01:31
Wes - for the record, I use a database at times when textfiles would suffice precisely because I find it easier than dealing with the files |