otóż mam problemik, ponieważ znalazłęm kod w internecie jako multiuploader... i wygląda on tak:

  1. <?php
  2. //katalog wysyłania.
  3. //change to fit your need eg. files, upload .... etc.
  4. $upload_dir = "uploads/klub_gal/";
  5. //liczba formularzy do wysyłania
  6. $num_files = 2;
  7. //maxymalny rozmiar plików w bajtach.
  8. $size_bytes =51200; //51200 bytes = 50KB.
  9. //Extensions you want files uploaded limited to.
  10. $limitedext = array(".gif",".jpg",".jpeg",".png",".txt",".nfo",".doc",".rtf",".htm",".dmg",".zip",".rar",".gz",".exe");
  11.  
  12.  
  13.  //check if the directory exists or not.
  14.  if (!is_dir("$upload_dir")) {
  15. die ("Błąd: Katalog <b>($upload_dir)</b> nie istnieje");
  16.  }
  17.  //check if the directory is writable.
  18.  if (!is_writeable("$upload_dir")){
  19. die ("Błąd: Katalog <b>($upload_dir)</b> jest niezapisywalny, Ustaw CHMOD (777)");
  20.  }
  21.  
  22.  
  23. //if the form has been submitted, then do the upload process
  24. //infact, if you clicked on (Upload Now!) button.
  25. if (isset($_POST['upload_form'])){
  26.  
  27.  echo "<h3>Wysyłanie:</h3>";
  28.  
  29.  //do a loop for uploading files based on ($num_files) number of files.
  30.  for ($i = 1; $i <= $num_files; $i++) {
  31.  
  32.  //define variables to hold the values.
  33.  $new_file = $_FILES['file'.$i];
  34.  $file_name = $new_file['name'];
  35.  //to remove spaces from file name we have to replace it with "_".
  36.  $file_name = str_replace(' ', '_', $file_name);
  37.  $file_tmp = $new_file['tmp_name'];
  38.  $file_size = $new_file['size'];
  39.  
  40.  #-----------------------------------------------------------#
  41.  # this code will check if the files was selected or not. #
  42.  #-----------------------------------------------------------#
  43.  
  44.  if (!is_uploaded_file($file_tmp)) {
  45. //print error message and file number.
  46. echo "File $i: Not selected.<br>";
  47.  }else{
  48.  #-----------------------------------------------------------#
  49.  # this code will check file extension  #
  50.  #-----------------------------------------------------------#
  51.  
  52.  $ext = strrchr($file_name,'.');
  53.  if (!in_array(strtolower($ext),$limitedext)) {
  54. echo "File $i: ($file_name) Wrong file extension. <br>";
  55.  }else{
  56.  #-----------------------------------------------------------#
  57.  # this code will check file size is correct  #
  58.  #-----------------------------------------------------------#
  59.  
  60.  if ($file_size > $size_bytes){
  61.  echo "File $i: ($file_name) Faild to upload. File must be <b>". $size_bytes / 1024 ."</b> KB. <br>";
  62.  }else{
  63.  #-----------------------------------------------------------#
  64.  # this code check if file is Already EXISTS. #
  65.  #-----------------------------------------------------------#
  66.  
  67.  if(file_exists($upload_dir.$file_name)){
  68.  echo "File $i: ($file_name) already exists.<br>";
  69.  }else{
  70.  #-----------------------------------------------------------#
  71.  # this function will upload the files. :) ;) cool #
  72.  #-----------------------------------------------------------#
  73.  if (move_uploaded_file($file_tmp,$upload_dir.$file_name)) {
  74.  echo "File $i: ($file_name) Uploaded.<br>";
  75.  }else{
  76. echo "File $i: Faild to upload.<br>";
  77.  }#end of (move_uploaded_file).
  78.  
  79.  }#end of (file_exists).
  80.  
  81.  }#end of (file_size).
  82.  
  83.  }#end of (limitedext).
  84.  
  85.  }#end of (!is_uploaded_file).
  86.  
  87.  }#end of (for loop).
  88.  # print back button.
  89.  echo "ť<a href="$_SERVER[PHP_SELF]">back</a>";
  90. ////////////////////////////////////////////////////////////////////////////////
  91. //else if the form didn't submitted then show it.
  92. }else{
  93. echo " <h3>Select files to upload!.</h3>
  94.  Max file size = ". $size_bytes / 1024 ." KB";
  95. echo " <form method="post" action="$_SERVER[PHP_SELF]" enctype="multipart/form-data">";
  96.  // show the file input field based on($num_files).
  97.  for ($i = 1; $i <= $num_files; $i++) {
  98.  echo "File $i: <input type="file" name="file". $i .""><br>";
  99.  }
  100. echo " <input type="hidden" name="MAX_FILE_SIZE" value="$size_bytes">
  101.  <input type="submit" name="upload_form" value="Wyślij Teraz">
  102.  </form>";
  103. }
  104. ?>


i moje pytanie, niestety niewiem jak go przerobić na FUNKCJE... obejmowałem to klauzulą function{} ale niestety nie wysyła pliku, a ten sam kod wrzuciłem do CZYSTEGO pliki i działa... chciałbym to przystosować do CMS-a, jPortala

ale nie umiem rolleyes.gif