[eluser]defectivereject[/eluser]
Morning All
Any chance anyone would know how i can count how many times a file has been downloaded.
I know how to update the mysql side of things to add 1 to a field.
the issue i'm having is using the anchor tags in my foreach function (Which loops through and finds all the files in my doc management system).
What i need to do is attach a function to the anchor that allows you to view/download the document, to trigger off the mysql function.
I've tried a few things like changing the anchor to a function to trigger off to a controller to download the file, but in doing that it downloads an empty file.
The file link
Code:
echo "<td>" . " " . anchor(base_url() . 'uploads/'.$files['doc_location'], 'ViewFile')."</td>";
i tried this but had no luck at all by changing the link function to
Code:
echo "<td>" . " " . anchor('download/downdoc/'.$files['doc_location'], 'Download')."</td>";
Code:
Controller - Download
function downdoc() {
$this->load->helper('download');
$data = file_get_contents("uploads/".$this->uri->segment(3));
$name= $this->uri->segment(3);
force_download($data,$name);
my mysql would be triggered to do something like this, but rather than the revision number being updated the no_of_times_downloaded column would be updated
Code:
$this->db->set('revision_number', 'revision_number + 1', FALSE)
any help would be great