thara Posted September 21, 2011 Share Posted September 21, 2011 hi... Im developing a web site to store a audio and video songs and it enable to download the songs for users. most of features I have finished at the moment. I need to count download users amount in a song and also need to count how many users view it only. actually I dont have any idea to do it using php. so anyone can me give any idea how to do it. thanks in advance for your help.... [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/247574-counting-downloaded-and-previewed-amont-belong-to-a-particular-file-in-a-web-sit/ Share on other sites More sharing options...
WebStyles Posted September 21, 2011 Share Posted September 21, 2011 that kind of depends how you have things set up. if you have a downloader.php page, that sends out the headers and grabs the file, forcing it to download, you can simply put a counter there, but this will be triggered every time a user starts a download, and does not necessarily mean they actually finish the downloads (they can cancel mid-way). Same applies for the viewing page, just set up a counter for each songID in your songs mysql table. (i.e. add an INT field and increment) with something like mysql_query("update `songs` set songCounter = songCounter +1 where songID = '$sid'",$conn); Quote Link to comment https://forums.phpfreaks.com/topic/247574-counting-downloaded-and-previewed-amont-belong-to-a-particular-file-in-a-web-sit/#findComment-1271305 Share on other sites More sharing options...
thara Posted September 21, 2011 Author Share Posted September 21, 2011 thanks dear... is there any way to count only finished downloads amount???? Quote Link to comment https://forums.phpfreaks.com/topic/247574-counting-downloaded-and-previewed-amont-belong-to-a-particular-file-in-a-web-sit/#findComment-1271341 Share on other sites More sharing options...
WebStyles Posted September 21, 2011 Share Posted September 21, 2011 as far as I know, there's really no way to correctly detect if the user finished the download, unless you embed some kind of applet in the download, or use flash, or something like that... (PHP is server-side, and the download happens on the client-side... you would need the client to send you some info AFTER the download, which will probably not happen). You can however count the size of each file in bytes, and use http headers to try and detect how many bytes have been downloaded, but this will be complicated and not as accurate as you would wish. You could also "guess" if download was completed based on the time since they start the download, the file size, the connection speed (which you need to establish before the download) and the time of the user's next activity on the website after the download. Also not a brilliant solution. Quote Link to comment https://forums.phpfreaks.com/topic/247574-counting-downloaded-and-previewed-amont-belong-to-a-particular-file-in-a-web-sit/#findComment-1271346 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.