CI 묻고 답하기

제목 파일 업로드 질문입니다.
글쓴이 생각하는여우 작성시각 2015/07/30 20:52:07
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 13531   RSS
안녕하세요

파일 업로드 부분에 질문이 있습니다.

현재 썸네일 이미지와 그냥 이미지 두개를 업로드 할려고 하는데요
 
public function uploadImage($file, $path) {
    $config['upload_path'] = $path;
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '10485760'; //1MB
    $config['max_width'] = '0';
    $config['max_height'] = '0';
    $this->upload->initialize($config);

    if (!$this->upload->do_upload($file)) {
        $error = array('error' => $this->upload->display_errors());
    } else {
        $data = array('upload_data' => $this->upload->data());
        return $data;
    }
}

public function uploadThumbnail($file, $path) {
    $config['upload_path'] = $path;
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '10485760'; //1MB
    $config['max_width'] = '0';
    $config['max_height'] = '0';
    $this->load->library('upload', $config);

    if (!$this->upload->do_upload($file)) {
        $error = array('error' => $this->upload->display_errors());
    } else {
        $data = array('upload_data' => $this->upload->data());
        return $data;
    }
}
 
<input type="file" name="thumbnail">
<input type="file" name="image">


이런식으로 함수를 2개를 만들어서 업로드를 하고 있습니다.

여기서 문제점이 있는게 항상 uploadThumbnail을 먼저 실행을 하고 uploadImage를 실행을 해야

파일이 업로드가 되더라구요.

uploadImage를 먼저 실행하거나 uploadThumbnail을 실행하지 않으면 파일 업로드가 안됩니다.

이거를 해결할 수 있는 방법이 있을까요?

예를 들어서 uploadImage만 업로드 해도 업로드가 이루어질 수 있도록요.

 
 다음글 일주일동안 헤메다 체크박스 선택 수정하기 관련 글 올립... (5)
 이전글 페이징 라이브러리 사용시 첫페이지 문제.. (6)

댓글

변종원(웅파) / 2015/07/30 22:35:47 / 추천 0
두 함수의 내용중 다른 점이 원하시는 답입니다. ^^
썸네일함수처럼 로딩 하세요.
letsgolee / 2015/07/31 18:03:28 / 추천 0
yes