By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

count number of bytes downloaded

P: 7
How we can keep track of number of bytes downloaded at client side
using PHP?.
or user has canceled the downloading? so that downloaded bytes can be entered in database
can you give me the code or any related function in PHP
I tried the code using echo readfile() function
but using this I can insert number of bytes downloaded but if user cancel the downloading then also it is showing that complete number of bytes downloaded
and it is geting inserted in database
Sep 5 '07 #1
Share this Question
Share on Google+
9 Replies


pbmods
Expert 5K+
P: 5,821
Heya, salil. Welcome to TSDN!

What is the significance of the number of bytes downloaded? Is this part of a billing system (User is charged per kb)? Are you trying to allow the User to resume an interrupted download? Are you sending infinite content until the User clicks the stop button?
Sep 5 '07 #2

P: 7
Heya, salil. Welcome to TSDN!

What is the significance of the number of bytes downloaded? Is this part of a billing system (User is charged per kb)? Are you trying to allow the User to resume an interrupted download? Are you sending infinite content until the User clicks the stop button?

hi,
This is not the part of billing system. but we are having a system where only
logged in user can download the document (.zip)
and if user has downloaded comletely then the report(bytes downloaded) must be stored in database. And if user has canceled the downloading or accidently it has stoped then also we must stored number bytes downloaded at user side.
Till now I am just looking to keep track of bytes downloaded, I have not decided about allowing user to resume an interrupted download.
I have tried all the possible code but it gives me the number of bytes that are outputed from server side so even if user has canceled the downloading it store complete number of bytes downloaded. same case happened if user canceled
downloading inbetween.
waiting for ur reply
Sep 6 '07 #3

pbmods
Expert 5K+
P: 5,821
Heya, Salil.

The problem with doing this on the server side is that PHP only cares about how much data it *sends* to the client, not how much data is actually *received* by the client.

If you wanted to determine how much data the client actually received, you'd probably need to write a PHP extension or an Apache module, neither of which is fast, easy, nor within the scope of the PHP forum.
Sep 7 '07 #4

P: 7
Hi
Will you tell me what is PHP extension?
and can I do this thing using socket programming in PHP or through Ajax? Plz tell me

and if that is also not possible then which language will support to make this program
Sep 8 '07 #5

pbmods
Expert 5K+
P: 5,821
Heya, Salil.

A PHP extension is an addition to PHP that you write and compile in C that can extend the functionality of PHP. In this case, since presumably Apache knows when a client has terminated a request, you might be able to write up an extension that provides the number of bytes sent and the type of termination (end of file or interrupted).

Good luck with that; that's far beyond my knowledge.

I'm not aware of any language that supports this behavior. ASP might be able to, though you might have to use IIS to make it work properly. I'm not sure. You might try asking about this in the Software Development forum.
Sep 8 '07 #6

P: 7
Hi
I got the code to count bytes downloaded at client side in JAVA.
So, now tell me can I include java program in PHP web page?
If yes, then the problem is the code is of 4 different pages and after compiling it create 11 class files so how I can include it in PHP web page?
Sep 12 '07 #7

IT Master2
P: 13
"Note: the paths depend on your installation for wamp & jdk"
"JDK could be 1_5 or higher"

first of all download javaBridge (search in google for it, i couldn't pos it here because it's about 10M)

then open: C:\wamp\Apache2\bin\php.ini

put in c:\wamp\php\ext the files: php_java.dll & JavaBidge.jar that are downloaded with JavaBridge.

then put the follwing:
Expand|Select|Wrap|Line Numbers
  1. .
  2. .
  3. .
  4. extension=php_java.dll
  5.  
  6. ;;;;;;;;;;;;;;;;;;;
  7. ; Module Settings ;
  8. ;;;;;;;;;;;;;;;;;;;
  9.  
  10. [java]
  11. java.java = "C:\Program Files\Java\jdk1.5.0_04\bin\javaw.exe"
  12. java.home="C:\Program Files\Java\jre1.5.0_04"
  13. java.class.path="C:\AppServ\php5\ext\JavaBridge.jar"
  14. java.library.path="C:\AppServ\php5\ext\php_java.dl l"
  15. java.library="C:\Program Files\Java\jdk1.5.0_04\jre\bin\server\jvm.dll"
  16. java.log_level=3
  17. .
  18. .
  19. .
//////////////////////////////////////////////

Restart the server and then play as you wish.

you should be able to see the java configuration in phpinfo.php

Best Regards.
Sep 12 '07 #8

pbmods
Expert 5K+
P: 5,821
Heya, Salil.

Please do not double-post your responses. All it does is add to the number of replies in your thread which makes it *less* likely that other members will want to take the time to read and respond to your question.
Sep 12 '07 #9

IT Master2
P: 13
to try what i post earlier, look in php.net for example for PHP-Java.

To include the JAVA classes use:

java_require("the path for the folder contains the java classes")
Sep 12 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.