PHP progress bar?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    PHP progress bar?

    Ok, I know ths is possible, an example is here:

    http://www.johnboy.com/php-upload-progress-bar/

    It uses the ob_flush() and flush() functions of PHP. From what I've read, these functions have no effect if mod_gzip is enabled in your apache server. I'm on a shared hosting plan with Dreamhost and they have mod_gzip enabled, but you can request to have it turned off for certain subdomains. I did so, but it seems that it didn't have an effect. Here is my code:

    Code:
    <?php
    ob_start();
    
    for ($i = 0; $i < 5; $i++) {
      echo $i . "<br>";
      ob_end_flush();
      ob_flush();
      flush();
      sleep(1);
      ob_start();
      }
    
    ob_end_flush();
    ?>
    This should output numbers from 0 to 5 over 5 seconds, sequentially, WHILE the page is loading. Instead it just takes 5 seconds for the page to load and then outputs the whole thing at once.

    I need to know how to make this work. I have a script that can take 30-45 seconds to run and I want something for my users to look at. Using Flash really isn't an option because I don't know flash. I COULD use AJAX and simply send a request to another script, but I'd like to try to avoid anything that requires Javascript.

    Please, if you guys could help me out, I'd be super grateful!
  • chathura86
    New Member
    • May 2007
    • 227

    #2
    please review that code properly

    specially the APC part, which does the magic of sending the upload progress


    Regards

    Comment

    • HaLo2FrEeEk
      Contributor
      • Feb 2007
      • 404

      #3
      Could you be a little more specific as to what I'm supposed to be looking at, everything looks right to me but it's not working, which is why I asked for help.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Do you have APC enabled?

        Comment

        • HaLo2FrEeEk
          Contributor
          • Feb 2007
          • 404

          #5
          I don't know what APC is. It sounds familiar, but refresh my memory, please.

          Comment

          • chathura86
            New Member
            • May 2007
            • 227

            #6
            All the details you need can be found in your tutorial



            for more info read the php manual



            Regards

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              The Alternative PHP Cache extension. Apparently it is necessary for this library to work.

              Comment

              Working...