PEAR::HTML::Progress example: Web-HTTP ProgressBar uploader
Author: Laurent Laville

examples

# Web-HTTP ProgressBar uploader

$Date: 2005/07/25 11:43:56 $

- Introduction
- Render options
- Ouput
- PHP source syntax highlight
- Play demo

## Introduction

This example requires :

- PEAR::HTML_Progress 1.1 or better.

This example allows you to upload files from a web browser to your web server and logs operations.

PEAR::HTML_QuickForm package is used to make and manage the form that will send file to your web server (top frame), while HTML_Progress is only used to display a horizontal progress meter running in indeterminate mode (bottom frame).

Be aware that your web server could returns a timeout on long upload operation, by running the HTML_Progress script (See technical notes below).

To logs all file uploads, we used the observer pattern with HTML_Progress_Observer class. Results are written in a series of files 'http4_[iso date].log', where iso date corresponding to current date in format YYYY-MM-DD.

[Top]

## Technical notes

The script time-out refers to the number of seconds a PHP page is given before the script is assumed to have failed and the page terminated. If you are uploading a large file the script that is receiving the transfer may time out before the file has been completely uploaded. To alter this setting you should insert the following code into your uploading page prior to creating any HTML_Progress and HTML_QuickForm objects.

1 | <?php set_time_limit(300); // five minutes ?>

See also: set_time_limit manual.

[Top]

## Render options

    increment = 10 (to make progress bar animation smoothest in indeterminate mode)

HTML_Progress::setIncrement()

    speed = 100 (to make progress bar animation smoothest)

HTML_Progress::setAnimSpeed()

    color = white
    with  = 1px
    style = inset

HTML_Progress_UI::setBorderAttributes()

    width            = 60
    font-size        = 10
    background-color = #C3C6C3

HTML_Progress_UI::setStringAttributes()

    active-color     = #000084
    inactive-color   = #3A6EA5
    width            = 25
    spacing          = 0
    background-image = download.gif

HTML_Progress_UI::setCellAttributes()

[Top]

## Output

### Screenshot

[Top]

## PHP source syntax highlight

The form file selection: Open source listing in a new window.

The progress meter in indeterminate mode: Open source listing in a new window.

[Top]

## Play demo

Run the script.

[Top]