CI 묻고 답하기

제목 사진을 여러장 올리려면 어떻게 해야할까요?
글쓴이 많이초보 작성시각 2015/06/18 15:04:54
댓글 : 1 추천 : 0 스크랩 : 0 조회수 : 13651   RSS
게시판 찾아봐도 없어서 질문드립니다.

            //업로드 설정
            // 사용자가 업로드 한 파일을 /static/user/ 디렉토리에 저장한다.
            $config['upload_path'] = './static/contents';
            // git,jpg,png 파일만 업로드를 허용한다.
               $config['allowed_types'] = 'gif|jpg|png';
                // 허용되는 파일의 최대 사이즈
            $config['max_size'] = '10000';
            // 이미지인 경우 허용되는 최대 폭
            $config['max_width']  = '1024';
            // 이미지인 경우 허용되는 최대 높이
            $config['max_height']  = '2048';
            $this->load->library('upload', $config);
            if ( ! $this->upload->do_upload("upload_img")){
                $imgurl = '';                
    
            }else{
                //이미지 url 추출
                $img_array = array('upload_data' => $this->upload->data());
                $img = $img_array['upload_data']['file_name'];
                $imgurl = '/static/contents/'.$img;
            }

메뉴얼 봐도 여러장을 올리는 방법은 안나오는데 어떻게들 처리하시나요??
 다음글 Mysql에 html형태의 데이터 입력시 문제. (1)
 이전글 안녕하세요 IIS7 index.php 지우기 질문입니...

댓글

한대승(불의회상) / 2015/06/18 15:57:22 / 추천 0
여러가지 방법이 있습니다만 ... 간단하게 아래처럼...
 $this->load->library('upload');
 
 $config['upload_path'] = './uploads/';
 $config['allowed_types'] = 'gif|jpg|png';
 $config['max_size'] = '100';
 $config['max_width']  = '1024';
 $config['max_height']  = '768';
 
 $files = $_FILES;

 foreach($files as $file)
 {

  $_FILES = $file;

  $this->upload->initialize($config);
  $this->upload->do_upload();
 }