Jump to content

Counting Downloaded And Previewed Amont Belong To A Particular File In A Web Sit


thara

Recommended Posts

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]

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.