개발 Q&A

제목 안녕하세요, 다중 파일업로드. 파일 업로드한 정보
카테고리 PHP
글쓴이 그동안 작성시각 2019/11/19 09:46:42
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 8901   RSS

안녕하세요, 궁금한 게 있어 문의 드립니다.

혹시 아시는 분 계시면 댓글 좀 부탁드립니다.

다중 파일 업로드 시, 업로드한 파일 정보를 어떻게 대입해야 될지 모르겠어요. (16~18번 line)

$this->upload->data() 인것 같아 대입도 해보고 했는데 안되더라구요.

 

$aco_count = $this->input->post('aco_count');
$file_count = count($_FILES["userfile_$i"]['name']);

for($i=1; $i <= $aco_count; $i++)
{	    
    $portfolio_img = $_FILES["userfile_$i"]['name'];

	//포트폴리오 이미지		    
	foreach ($portfolio_img as $file_count)                         //$portfolio_img를  $file_count 개수만큼 반복          
	{  
	    $data = array(                                                                     
		  'db_table_name' => 'profile_portfolio_img' ,                                     
		  'mem_id' => $this->session->userdata('mem_id') ,                                 
		  'pbs_id' => $this->session->userdata('edit_pbs_id') ,                             
		  'pport_id' => $pport_id ,                                                        
		  'portfolio_asis_img_name' => 'test_asis_img_5',           //업로드 전 파일명
		  'portfolio_tobe_img_path' => 'test_tobe_img_5' ,          //업로드된 서버 저장경로 ex)/path/upload/
		  'portfolio_tobe_img_name' => 'test_tobe_nanme_5' ,        //업로드된 파일명	 ex)abc.jpg            
          'created_by' => $this->session->userdata('user_nm') ,                            
          'created_ip' => $this->session->userdata('ip_address')                                         
	    );
        $result = $this->profile_portfolio_img_m->my_profile_add_06_insert($data);     //모델에 insert 요청
    }
}

 

 

 

 다음글 cron으로 백업파일을 받고있는데요..경로문제.. (4)
 이전글 mysql 쿼리 where문을 만들려고 하는데 이렇게 ... (6)

댓글

변종원(웅파) / 2019/11/19 10:18:20 / 추천 0

1개 업로드 해보시지 않으셨는지요? 1번 실행하는 것과 여러번 실행하는 것의 차이밖에 없습니다.

매뉴얼 보시고 아래 함수 실행해서 그 결과를 $data 배열에 적절히 나눠서 넣으시면 됩니다.

$this->upload->data()

참고 실행예제 http://sample.cikorea.net/ci20/sample_view/class/upload

kaido / 2019/11/19 10:28:19 / 추천 0

사실 CI 업로드 라이브러리가 어렵다면 네이티브 형태로 돌아다니는 PHP 업로드 라이브러리를 넣고 사용하셔도 무방 합니다

네이티브로 넣어보고 CI 업로드 라이브러리 천천히 보시면 방법은 사실 같다는걸 알게 됩니다.

같은 PHP 하늘아래 로직이 다를리가 없지요.

신일 / 2019/11/25 12:59:22 / 추천 0
두분 답변 감사합니다^^