개발 Q&A

제목 파일없이 글수정하기기능이 안됩니다..
카테고리 PHP
글쓴이 코린이 작성시각 2018/03/13 17:45:32
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 8914   RSS
public function desc()
    {
        $config['upload_path'] = 'C:\xampp\htdocs\admintour2\images';
		$config['allowed_types'] = 'gif|jpg|png';
		$config['max_size']	= '20000';
		$config['max_width']  = '2000';
		$config['max_height']  = '2000';
		$this->load->library('upload', $config);
        
        
		if($this->upload->do_upload()) {

            $imagepath = $this->upload->data();
			
			$region=$this->input->post('region', TRUE);
			$pname=$this->input->post('pname', TRUE);
            $supply=$this->input->post('supply', TRUE);
            $companycode=$this->input->post('companycode', TRUE);
            $gubun=$this->input->post('gubun', TRUE);
            
            $supplypcode=$this->input->post('supplypcode', TRUE); //공급사상품코드
            $tourtype=$this->input->post('tourtype', TRUE); //여행형태
            $pschedule=$this->input->post('pschedule', TRUE); //기간(일정)
            $startdate=$this->input->post('startdate', TRUE); //출발
            $returndate=$this->input->post('returndate', TRUE); //귀국
            $price=$this->input->post('price', TRUE); //가격
            $included=$this->input->post('included', TRUE); //포함내역
            $notincluded=$this->input->post('notincluded', TRUE); //불포함내역
            $airline=$this->input->post('airline', TRUE); //항공
            $hotel=$this->input->post('hotel', TRUE); //숙소
            $scheduletable=$this->input->post('scheduletable', TRUE); //일정표
            $noticeinfo=$this->input->post('noticeinfo', TRUE); //주의사항
            $starttime=$this->input->post('starttime', TRUE); //출발시간
            $returntime=$this->input->post('returntime', TRUE); //귀국시간
            
            $pid=$this->input->post('pid', TRUE);
            
            
			$this->board_model->update( $imagepath, $region, $pname, $supply, $companycode, $gubun,
                                      $supplypcode, $tourtype, $pschedule, $startdate, $returndate, $price,
                                      $included, $notincluded, $airline, $hotel, $scheduletable, $noticeinfo,
                                      $starttime, $returntime, $pid);
			redirect('/board/index/');
			exit;
            
		}
        else{
            $pid=$this->uri->segment(3);
			$data['desc'] = $this->board_model->desc($pid);
			$this->load->view('desc', $data);
		}
    }
function update($imagepath, $region, $pname, $supply, $companycode, $gubun,
                    $supplypcode, $tourtype, $pschedule, $startdate, $returndate, $price,
                    $included, $notincluded, $airline, $hotel, $scheduletable, $noticeinfo,
                    $starttime, $returntime, $pid) 
	{
		$data=array(
            'imagepath'=>$imagepath['file_name'],
            
			'region'=>$region,
			'pname'=>$pname,
            'supply'=>$supply,
            'companycode'=>$companycode,
			'gubun'=>$gubun,
            
            'supplypcode'=>$supplypcode,
			'tourtype'=>$tourtype,
            'pschedule'=>$pschedule,
            'startdate'=>$startdate,
			'returndate'=>$returndate,
            'price'=>$price,
            'included'=>$included,
			'notincluded'=>$notincluded,
            'airline'=>$airline,
            'hotel'=>$hotel,
			'scheduletable'=>$scheduletable,
            'noticeinfo'=>$noticeinfo,
			'starttime'=>$starttime,
            'returntime'=>$returntime
            
		);
		$this->db->where('pid',$pid);
		$this->db->update('product_tourapp',$data);
    }

순서대로 컨트롤러 모델입니다.

제가 글을 수정하려는데 거기에 원래 사진파일이 들어가있습니다. 그런데 불러올 때 사진경로로 해서

기존 사진파일이 보여지긴 하는데 업로드하는 펑션에 <?php echo form_open_multipart('board/desc/');?> 여기에 넣어놓을 수가

없겠더라구요. 그래서 이것저것 건드려보는데 도저히 답이 안나오네요... 제발 좀 도와주세요.. 기존에 있는 글에

사진파일을 새로 안 선택하고 그냥 글을 수정하는 방법은 없나요?

 다음글 리눅스 npm 하위 모듈 설치 에러 문의드립니다. (1)
 이전글 리눅스 아파치 네임서버 등록 문의 드립니다~~ (2)

댓글

kaido / 2018/03/13 18:39:11 / 추천 0

이럴땐 네이티브 PHP문법이 간절해 지죠. 

$_FILES 관련으로 검색해 보세요.

저같은 경우엔 먼저 파일 업로드 했는지 체크 하고 나서 업로드 라이브러리를 실행 합니다.

약간 못 미덥더라구요 CI 업로드 라이브러리가 ( ..)

이제다시 / 2018/03/14 11:22:05 / 추천 0

if($this->upload->do_upload()) { 

프로그램을 파일 업로드가 성공하였을 경우에만 업데이트문을 시작하게 만드셨내요

당연히 파일이 없다면 항상 실패가 나겠죠

 

수정기능은 파일 업로드와는 상관없이 진행하시고, 파일이 있을 경우에만

해당 필드를 업데이트 하면 될거 같습니다. 

 

참고로 input file 의 value 에는 보안상 어떤것도 넣을 수 없습니다.