count number of bytes downloaded

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • salil123
    New Member
    • Sep 2007
    • 7

    count number of bytes downloaded

    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
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    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?

    Comment

    • salil123
      New Member
      • Sep 2007
      • 7

      #3
      Originally posted by pbmods
      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

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        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.

        Comment

        • salil123
          New Member
          • Sep 2007
          • 7

          #5
          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

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            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.

            Comment

            • salil123
              New Member
              • Sep 2007
              • 7

              #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?

              Comment

              • IT Master2
                New Member
                • Aug 2007
                • 13

                #8
                "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:
                Code:
                .
                .
                .
                extension=php_java.dll
                
                ;;;;;;;;;;;;;;;;;;;
                ; Module Settings ;
                ;;;;;;;;;;;;;;;;;;;
                
                [java]
                java.java = "C:\Program Files\Java\jdk1.5.0_04\bin\javaw.exe"
                java.home="C:\Program Files\Java\jre1.5.0_04"
                java.class.path="C:\AppServ\php5\ext\JavaBridge.jar"
                java.library.path="C:\AppServ\php5\ext\php_java.dl l"
                java.library="C:\Program Files\Java\jdk1.5.0_04\jre\bin\server\jvm.dll"
                java.log_level=3
                .
                .
                .
                //////////////////////////////////////////////

                Restart the server and then play as you wish.

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

                Best Regards.

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  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.

                  Comment

                  • IT Master2
                    New Member
                    • Aug 2007
                    • 13

                    #10
                    to try what i post earlier, look in php.net for example for PHP-Java.

                    To include the JAVA classes use:

                    java_require("t he path for the folder contains the java classes")

                    Comment

                    Working...