You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
813 B

7 years ago
  1. <?php
  2. class WB_Upload extends CI_Upload {
  3. public function __construct()
  4. {
  5. parent::__construct();
  6. }
  7. function fixFilesArray($field="userfile")
  8. {
  9. // iterate over each uploaded file
  10. foreach ($_FILES[$field] as $key => $value) {
  11. foreach ($value as $noKey => $noValue) {
  12. $files[$noKey][$key] = $noValue;
  13. }
  14. }
  15. $_FILES[$field] = $files;
  16. return $files;
  17. }
  18. function do_multi_upload($field="userfile"){
  19. $data = array();
  20. $files = $this->fixFilesArray($field);
  21. unset($_FILES);
  22. foreach ($files as $file) {
  23. $_FILES['userfile'] = $file;
  24. if (!$this->do_upload('userfile') )
  25. {
  26. //업로드 실패
  27. $data[] = array('error' => $this->display_errors());
  28. }
  29. else
  30. {
  31. $data[] = array('upload_data' => $this->data());
  32. }
  33. }
  34. return $data;
  35. }
  36. }