1. <?php
  2. header("Cache-Control: no-cache, must-revalidate");
  3. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  4.  
  5. if (@$_GET['id']) {
  6. echo json_encode(uploadprogress_get_info($_GET['uuid']));
  7. exit();
  8. }
  9. $uuid = uniqid();
  10. ?>
  11. <form enctype="multipart/form-data" action="aaa.php" method="POST">
  12. <input name="img" type="file" /><br />
  13. <input id="progress_key" name="UPLOAD_IDENTIFIER" type="hidden" value="<?php echo $uuid; ?>" />
  14.  
  15. <input type="submit" value="Wyslij"/>
  16. <span id="uploadprogressbar" class="progressbar">0%</span>
  17.  
  18. </form>
  19. <script type="text/javascript">
  20.  
  21. var progress_key = '<?php echo $uuid; ?>';
  22.  
  23. // this sets up the progress bar
  24. $(document).ready(function() {
  25. $("#uploadprogressbar").progressBar();
  26. });
  27.  
  28. // fades in the progress bar and starts polling the upload progress after 1.5seconds
  29. function beginUpload() {
  30. // uses ajax to poll the uploadprogress.php page with the id
  31. // deserializes the json string, and computes the percentage (integer)
  32. // update the jQuery progress bar
  33. // sets a timer for the next poll in 750ms
  34. $("#uploadprogressbar").fadeIn();
  35.  
  36. var i = setInterval(function() {
  37. $.getJSON("aaa.php?id=" + progress_key, function(data) {
  38. if (data == null) {
  39. clearInterval(i);
  40. location.reload(true);
  41. return;
  42. }
  43.  
  44. var percentage = Math.floor(100 * parseInt(data.bytes_uploaded) / parseInt(data.bytes_total));
  45. $("#uploadprogressbar").progressBar(percentage);
  46. });
  47. }, 1500);
  48. }
  49. </script>
  50. <?php
  51. $plik_tmp = $_FILES['img']['tmp_name'];
  52. $nazwa = $_FILES['img']['name'];
  53. $rozmiar = $_FILES['img']['size'];
  54. if(is_uploaded_file($plik_tmp)) {
  55. move_uploaded_file($plik_tmp, "$nazwa");
  56. echo "Plik: <strong>$nazwa</strong> o rozmiarze
  57. <strong>$rozmiar bajtów</strong> został przesłany na serwer!";
  58. }
  59. ?>

Skrypt nie działa
Czy link musi być:
  1. $.getJSON("aaa.php?id=" + progress_key, function(data)

Prosze o pomoc

ref

ref