oferweisglass
asked on
file downloads counter
Need to build counter to file downloads
the file is on hosting server and it should be page to download the file (save as)
any ideas?
the file is on hosting server and it should be page to download the file (save as)
any ideas?
ASKER
how many tables should be in the database? and what fields?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<a href="/files/myfile.zip">D
you can use:
<a href="/download.php?file=m
Then, the file 'download.php' would contain something like:
<?php
$filename = $_GET['file'];
$result = mysql_query("SELECT downloads FROM table_files WHERE filename='{$filename}'";
$downloads = $results[0];
// Increment the count
$downloads++;
// Upload the new count in to the database
mysql_query("UPDATE files_table SET download='{$downloads}' WHERE filename='{$filename}'");
// Now, redirect to the file
header("Location: /files/$filename");
?>
You would want some more error checking, but this is the basic idea.