Poszukuję gotowego darmowego skryptu uploadu, umożliwiającego upload wielu plików naraz. O ile dobrze wiem w samym php nie da się tego zrobić. Znalazłem coś takiego jak swfupload i ściagnąłem zarówno pliki źródłowe jak i gotowe przykłady. Z plików źródłowych to ja nic nie wykombinuje:) Ale jest gotowy szablon, który niby działa, ale nie uploaduje plików do folderu. Czy mógłby mi ktoś pomoć zmodyfikować kod, tak żeby mi przenosiło do folderu? Wklejam tylko kody php, ale są też pliki javy, nie wiem czy akurat to mojego problemu potrzebne.

index.php


  1. <!--c1--><div class='codetop'>Kod</div><div class='codemain'><!--ec1--><?php
  2.     session_start();
  3.  
  4.     if (count($_FILES)) {
  5.         // Handle degraded form uploads here.  Degraded form uploads are POSTed to index.php.  SWFUpload uploads
  6.         // are POSTed to upload.php
  7.     }
  8.  
  9. ?>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11.  
  12. <html xmlns="http://www.w3.org/1999/xhtml" >
  13. <head>
  14. <title>SWFUpload Demos - Multi-Instance Demo</title>
  15. <link href="../css/default.css" rel="stylesheet" type="text/css" />
  16. <script type="text/javascript" src="../swfupload/swfupload.js"></script>
  17. <script type="text/javascript" src="js/swfupload.queue.js"></script>
  18. <script type="text/javascript" src="js/fileprogress.js"></script>
  19. <script type="text/javascript" src="js/handlers.js"></script>
  20. <script type="text/javascript">
  21.         var upload1, upload2;
  22.  
  23.         window.onload = function() {
  24.             upload1 = new SWFUpload({
  25.                 // Backend Settings
  26.                 upload_url: "upload.php",
  27.                 post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
  28.  
  29.                 // File Upload Settings
  30.                 file_size_limit : "102400",    // 100MB
  31.                 file_types : "*.*",
  32.                 file_types_description : "All Files",
  33.                 file_upload_limit : "10",
  34.                 file_queue_limit : "0",
  35.  
  36.                 // Event Handler Settings (all my handlers are in the Handler.js file)
  37.                 file_dialog_start_handler : fileDialogStart,
  38.                 file_queued_handler : fileQueued,
  39.                 file_queue_error_handler : fileQueueError,
  40.                 file_dialog_complete_handler : fileDialogComplete,
  41.                 upload_start_handler : uploadStart,
  42.                 upload_progress_handler : uploadProgress,
  43.                 upload_error_handler : uploadError,
  44.                 upload_success_handler : uploadSuccess,
  45.                 upload_complete_handler : uploadComplete,
  46.  
  47.                 // Button Settings
  48.                 button_image_url : "XPButtonUploadText_61x22.png",
  49.                 button_placeholder_id : "spanButtonPlaceholder1",
  50.                 button_width: 61,
  51.                 button_height: 22,
  52.                 
  53.                 // Flash Settings
  54.                 flash_url : "../swfupload/swfupload.swf",
  55.                 
  56.  
  57.                 custom_settings : {
  58.                     progressTarget : "fsUploadProgress1",
  59.                     cancelButtonId : "btnCancel1"
  60.                 },
  61.                 
  62.                 // Debug Settings
  63.                 debug: false
  64.             });
  65.  
  66.             upload2 = new SWFUpload({
  67.                 // Backend Settings
  68.                 upload_url: "upload.php",
  69.                 post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
  70.  
  71.                 // File Upload Settings
  72.                 file_size_limit : "200",    // 200 kb
  73.                 file_types : "*.jpg;*.gif;*.png",
  74.                 file_types_description : "Image Files",
  75.                 file_upload_limit : "10",
  76.                 file_queue_limit : "5",
  77.  
  78.                 // Event Handler Settings (all my handlers are in the Handler.js file)
  79.                 file_dialog_start_handler : fileDialogStart,
  80.                 file_queued_handler : fileQueued,
  81.                 file_queue_error_handler : fileQueueError,
  82.                 file_dialog_complete_handler : fileDialogComplete,
  83.                 upload_start_handler : uploadStart,
  84.                 upload_progress_handler : uploadProgress,
  85.                 upload_error_handler : uploadError,
  86.                 upload_success_handler : uploadSuccess,
  87.                 upload_complete_handler : uploadComplete,
  88.  
  89.                 // Button Settings
  90.                 button_image_url : "XPButtonUploadText_61x22.png",
  91.                 button_placeholder_id : "spanButtonPlaceholder2",
  92.                 button_width: 61,
  93.                 button_height: 22,
  94.                 
  95.                 // Flash Settings
  96.                 flash_url : "../swfupload/swfupload.swf",
  97.  
  98.                 swfupload_element_id : "flashUI2",        // Setting from graceful degradation plugin
  99.                 degraded_element_id : "degradedUI2",    // Setting from graceful degradation plugin
  100.  
  101.                 custom_settings : {
  102.                     progressTarget : "fsUploadProgress2",
  103.                     cancelButtonId : "btnCancel2"
  104.                 },
  105.  
  106.                 // Debug Settings
  107.                 debug: false
  108.             });
  109.  
  110.          }
  111.     </script>
  112. </head>
  113. <body>
  114. <div id="header">
  115.     <h1 id="logo"><a href="../">SWFUpload</a></h1>
  116.     <div id="version">v2.2.0</div>
  117. </div>
  118. <div id="content">
  119.     <h2>Multi-Instance Demo</h2>
  120.     <form id="form1" action="index.php" method="post" enctype="multipart/form-data">
  121.         <p>This page demonstrates how multiple instances of SWFUpload can be loaded on the same page.
  122.             It also demonstrates the use of the graceful degradation plugin and the queue plugin.</p>
  123.         <table>
  124.             <tr valign="top">
  125.                 <td>
  126.                     <div>
  127.                         <div class="fieldset flash" id="fsUploadProgress1">
  128.                             <span class="legend">Large File Upload Site</span>
  129.                         </div>
  130.                         <div style="padding-left: 5px;">
  131.                             <span id="spanButtonPlaceholder1"></span>
  132.                             <input id="btnCancel1" type="button" value="Cancel Uploads" onclick="cancelQueue(upload1);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
  133.                             <br />
  134.                         </div>
  135.                     </div>
  136.                 </td>
  137.                 <td>
  138.                     <div>
  139.                         <div class="fieldset flash" id="fsUploadProgress2">
  140.                             <span class="legend">Small File Upload Site</span>
  141.                         </div>
  142.                         <div style="padding-left: 5px;">
  143.                             <span id="spanButtonPlaceholder2"></span>
  144.                             <input id="btnCancel2" type="button" value="Cancel Uploads" onclick="cancelQueue(upload2);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
  145.                             <br />
  146.                         </div>
  147.                     </div>
  148.                 </td>
  149.             </tr>
  150.         </table>
  151.     </form>
  152. </div>
  153. </body>
  154. </html><!--c2--></div><!--ec2-->



upload.php

  1. <!--c1--><div class='codetop'>Kod</div><div class='codemain'><!--ec1--><?php
  2.     if (isset($_POST["PHPSESSID"])) {
  3.         session_id($_POST["PHPSESSID"]);
  4.     }
  5.     session_start();
  6.  
  7.     
  8.  
  9.  
  10.     // In this demo we trigger the uploadError event in SWFUpload by returning a status code other than 200 (which is the default returned by PHP)
  11.     if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
  12.         // Usually we'll only get an invalid upload if our PHP.INI upload sizes are smaller than the size of the file we allowed
  13.         // to be uploaded.
  14.         header("HTTP/1.1 500 File Upload Error");
  15.         if (isset($_FILES["Filedata"])) {
  16.             echo $_FILES["Filedata"]["error"];
  17.         }
  18.         exit(0);
  19.     }
  20.     
  21. ?><!--c2--></div><!--ec2-->