-1

I am creating my document-sharing site using wordpress. But I have problems when doing a Upload-file form and Download tracking. Of course I make it front-end. I want to ask you for help about how can I track the uploaded file --> To make "Popular Download Document" and make "Download History" in user's profile. Or could you help me something like that. Many thanks !

Pratik Joshi
  • 11,485
  • 7
  • 41
  • 73
Tienluc
  • 25
  • 3

2 Answers2

0

To get track of downloaded document, use one field in your database table named as num_downloads. See when you hit some download page like abc.com/downloads.php?id=10, now downloads.php will be your page and you have query string id=10. So for that product increment/update its num_downloads by one as soon as it gets hit. So 20 times Only i clicked on link, then count for that file will be +20 than original num_downloads count.

So roughly your table structure for say table files will be

id   name_of_file        num_downloads
1    harry potter book   100

Where num_downloads field will increment by one on each hit for particular file.

Pratik Joshi
  • 11,485
  • 7
  • 41
  • 73
  • Okay. I understood. Let me try this. Thank you so much ! – Tienluc Jun 07 '15 at 17:49
  • By the way, I have one more question. How can I get user downloaded file? For example, when an user logged-in and download a file, then they go to "Download History" and that file was there @jQuery.PHP.Magento.com – Tienluc Jun 07 '15 at 18:03
  • @Tienluc you are just 1 step away from googling . Here is ready made answer just for you http://stackoverflow.com/questions/8485886/force-file-download-with-php-using-header – Pratik Joshi Jun 07 '15 at 18:19
0
$mysql_query = "UPDATE `download` SET `counter_download` = counter_download + 1";

// Execute your Query with your mysql or mysqli or pdo ...
// Then, let user download file with php function force_download().

force_download("/folder/file.zip");

Finally call your column where you insert download counter.

Anass
  • 2,101
  • 2
  • 15
  • 20
  • Could you help me solve this, as I had asked, how can I get user downloaded file? For example, when an user logged-in and download a file, then they go to "Download History" and that file was there. Thank you – Tienluc Jun 07 '15 at 18:05
  • do you want these data will be stored in a new mysql table for tracking downloads? – Anass Jun 07 '15 at 18:16