Advertisement
Guest User

Progress.php

a guest
Mar 23rd, 2011
195
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     //We don't want to be caching this, right? =)
  4.     header('Expires: Tue, 08 Oct 1991 00:00:00 GMT');
  5.     header('Cache-Control: no-cache, must-revalidate');
  6.  
  7.     $url = basename($_SERVER['SCRIPT_FILENAME']);
  8.    
  9.     if ($_GET["progress_key"])
  10.     {
  11.         echo "GET success!";
  12.         $status = apc_fetch('upload_'.$_GET['progress_key']);
  13.         var_dump($status);
  14.         die;
  15.     }
  16.     else
  17.        
  18. ?>
  19. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"></script>
  20. <script>
  21.     $(document).ready(function() {
  22.  
  23.         setInterval(function() {
  24.             $.get(
  25.                 "<?php echo $url; ?>?progress_key=<?php echo $_GET['uid']; ?>&randval="+ Math.random(),
  26.                 {  
  27.                     // Get request to the current URL (upload_frame.php) which calls the code at the top of
  28.                     // the page.  It checks the file's progress based on the file id "progress_key=" and
  29.                     // returns the value with the function below:
  30.                 },
  31.                 function(data) {    //return information back from jQuery's get request
  32.  
  33.                     console.log("Data: " + data);
  34.                                      
  35.                     $('#progress_container').fadeIn(100);   // Fade in progress bar    
  36.  
  37.                     $('#progress_bar').width(data +"%");    // Set width of progress bar
  38.                                                             // based on the $status value (set at the top of this page)
  39.  
  40.                     $('#progress_completed').html(parseInt(data) +"%");     // Display the % completed
  41.                                                                             // within the progress bar
  42.                 }
  43.             )
  44.         }, 500);    //Interval is set at 500 milliseconds (the progress bar will refresh every .5 seconds)
  45.  
  46.     });
  47. </script>
  48. <body>
  49. <div>TEST</div>
  50. <?php
  51.  
  52.     if (isset($_GET["uid"]))
  53.     {
  54.         echo "UID: ".$_GET["uid"];
  55.     }
  56.  
  57. ?>
  58. </body>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement