php + ajax file upload progress bar


Find an article PHP AJAX File Upload Progress Meter Updates, on how to use php Pear: HTML_AJAX produced with the progress of the file upload, Below are the upload when I test the diagram

ajax with the progress of the upload


Code is divided into the following sections:

demo.php – dealing with the upload process
PLAIN TEXT
PHP:

    1.
       <? php
    2.
      
    3.
       include 'UploadProgressMeter.class.php';
    4.
      
    5.
       $ fileWidget = new UploadProgressMeter ();
    6.
      
    7.
       if ($ fileWidget-> uploadComplete ()) (
    8.
               / / Upload the end of the time, send a js from the iframe to the main window that all ok
    9.
               echo $ fileWidget-> finalStatus ();
   10.
      
   11.
               / / Handling upload the file …
   12.
      
   13.
               exit;
   14.
       )
   15.
       «>

demoserver.php – ajax service-js, the use of Pear: HTML_AJAX, direct call UploadProgressMeterStatus category
PLAIN TEXT
HTML:

    1.
       <script src="http://www.ooso.net/demoserver.php?client=main,request,httpclient,dispatcher,json,util" type="text/javascript"> </ script>
    2.
       <script src="http://www.ooso.net/demoserver.php?stub=UploadProgressMeterStatus" type="text/javascript"> </ script>
    3.
       <? php echo $ fileWidget-> renderIncludeJs ();?>

The progress of the style sheet
PLAIN TEXT
CSS:

    1.
       . progressBar (
    2.
         position: relative;
    3.
         padding: 2px;
    4.
         width: 300px;
    5.
         height: 40px;
    6.
         font-size: 14px;
    7.
       )
    8.
       . progressBar. background (
    9.
         border: solid 1px black;
   10.
         width: 270px;
   11.
         height: 20px;
   12.
       )
   13.
       . progressBar. bar (
   14.
         position: relative;
   15.
         background-color: blue;
   16.
         width: 0px;
   17.
         height: 20px;
   18.
       )

Form part of
PLAIN TEXT
HTML:

    1.
       <form action="demo.php" method="post" enctype="multipart/form-data"> renderFormExtra ();?>>
    2.
       <? php echo $ fileWidget-> renderHidden ();?> </ form> <form action="demo.php" method="post" enctype="multipart/form-data"> <label> Select File: </ label>
    3.
       <div> <? php echo $ fileWidget-> render ();?>
    4.
       <? php echo $ fileWidget-> renderProgressBar ();?> </ div>
    5.
       </ form>

demo downloads – the password is www.ooso.net
The author's visit svn

Other similar projects:
http://pdoru.from.ro/ – to the form and to patch together compile php
http://www.ugia.cn/?p=54 – socket to upload files and show the progress of the

Leave a Reply

Copyright © 2007 - Antivirus—Kaspersky key|kav7.0 key|kis7.0 key|kav8.0 key|kis8.0 key

  • Partner links