2011-01-13 3 views
0

jpg 또는 png 이미지 파일을 업로드 할 때마다이 오류가 발생합니다.CodeIgnitor 업로드 오류 : 업로드하려는 파일 형식이 허용되지 않습니다.

내 양식 :

<form action="/merchant/process_create" method="post" id="merchant_signup" enctype="multipart/form-data"> 
<?php 
echo form_label('Select Your Logo or Relevant Image:', 'image'); 
echo "<br />"; 
?> 
<input type="file" name="image" size="20" id="image" /> 
<?php 
echo "<br />"; 
echo "<br />"; 

echo form_submit('submit', 'Create Account'); 
?> 

컨트롤러의 업로드 부분 :

//upload the image 
      $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/uploads/'; 
      $config['allowed_types'] = 'jpg|jpeg|gif|png'; 
      $config['max_size'] = '2000'; 
      $config['max_width'] = '0'; 
      $config['max_height'] = '0'; 
      $config['file_name'] = time() . rand(); 
      $config['remove_spaces'] = TRUE; 

      $this->load->library('upload', $config); 

      if (! $this->upload->do_upload('image')) 
      { 
       $data= array('error' => $this->upload->display_errors('', '<br />')); 

       //reload the view 
       $this->load->view('header'); 

       $this->load->view('merchant_create_form', $data); 

       $this->load->view('footer'); 


      } else { 


       //make the insert array 
       $merchant_data = array(
        'user_id'   => $this->session->userdata('user_id'), 
        'name'    => $this->input->post('name'), 
        'uri_slug'   => $this->input->post('uri_slug'),...... 

내가 잘못하고있는 무슨 단서가 없다, 도와주세요. 감사합니다. $config['file_name'] 그것을 제거하는 필요가 시도 될 이유 닉

+0

테스트 할 파일이 실제 PNG 또는 JPG입니까? CI는 파일 확장자가 아닌 $ config [ 'allowed_types']에서 일치 항목을 업로드 한 파일의 MIME 유형을 검사합니다. –

+0

lib, $ this-> load-> library ('upload');를로드하고 있습니까? – shin

답변

0

을 주석 라인을, $의 설정 [ 'FILE_NAME'] = 시간() ... 볼 수 없습니다. 랜드(); 그리고 무슨 일이 일어 났는지 알려주세요.

// $config['file_name'] = time() . rand(); 
+0

file_name config가 지정되면 파일 확장명도 추가해야합니다. 당신의 도움을 주셔서 감사합니다!! - Nick Roskam –

0

application/config/mimes.php 파일에 필요한 MIME 유형이 들어 있는지 확인하십시오. 그렇지 않으면 업로드 클래스의 do_upload 메소드에 var_dump()를 두어 일이 실패한 곳을 확인하십시오.

관련 문제