PEAR Progress2 logo

HTML_Progress2 : The Definitive Guide

Chapter 11.  How to to implement an AJAX Upload with Progress Bar solution

Table of Contents

AJAX with PEAR package HTML_AJAX
HTML side
Server side
Examples (full source code)

AJAX with PEAR package HTML_AJAX

[Caution] Caution

First of all, you need to learn, if its not yet done, the PEAR package HTML_AJAX features before to continue reading.

HTML_Progress2 use help of PEAR::HTML_AJAX to make asynchronous connection with your server. That means, you need to define :

  • A script that will handle all polling loop requests by your browser. I've decided (but you are free to make it different) to build an auto server (auto_server.php) rather than built a single file for each ajax progress bar.

  • Identify what ressources (proxy (server, auto server), client librairies) to use with HTML_Progress2::registerAjax() at design-time of your progress bar.

  • Identify the proxy used, invoked on polling loop by JavaScript variables : HTML_Progress2.serverClassName, HTML_Progress2.serverMethodName or HTML_Progress2.serverCallback (if it's a simple php function, and not method-class).

  • Don't forget to give identifier to track down the file upload, on JS variable HTML_Progress2.requestArgs. It's a key-value pair with always upload_identifier as key. Value is free.

  • When upload is over, HTML_Progress2 need to know with JS variable HTML_Progress2.onComplete what to do. Default behavior is to reload the same page with query string "reload=true".

HTML_Progress2 : The Definitive Guide v 2.4.0 : April 20, 2007