2012-04-01 4 views
0

나는 이미 1 시간 30 분과 함께 싸우고 있지만 문제를 찾을 수 없습니다. 나는 CodeIgniter의 업로드 기능을 사용하고 있지만, 항상 업로드 실패 -codeigniter에 업로드 된 사진이 없습니다.

컨트롤러 -

// Uploads the picture to server 
    public function uploadPicture() 
    { 
    $this->load->helper(array('form', 'url')); 
    $this->load->helper('url'); 
     $config['upload_path'] = './images/pictures/'; 
     $config['allowed_types'] = 'gif|jpg|png'; 
     $config['max_size'] = '700'; 
     $config['max_width'] = '1024'; 
     $config['max_height'] = '768'; 

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

     $this->upload->do_upload(); 

     if (! $this->upload->do_upload()) 
     { 
      $data = array('upload_data' => $this->upload->data());  

      var_dump($data); 
     //redirect('/profile/changePicture', 'refresh'); 
     } 
     else 
     { 
     redirect('/profile/changePicture', 'refresh');    
     } 
    } 

보기 -

난을 선택하면 나도 어떤 사진을 선택하지 않거나 후
<form class="fix-this form" method="post" action="/savieno/profile/uploadPicture" enctype="multipart/form-data"> 
        <div class="formfield">      
         <label id="current-password-error" class="input-error" style="display: none;"></label>   
         <span class="profile">Tava bilde: </span>         
         <input id="picture" name="picture" class="with-label" style="width: 270px;" type="file" placeholder="Tava bilde" /> 
         <label>*</label> 
    </div>      
        <input type="submit" id="submit" value="Labot Profilu" name="edit" class="fix-this" />   
    </form> 

그림, 그것은 나에게 detials와 var_dump를 준다 -

array 
    'upload_data' => 
    array 
     'file_name' => string '' (length=0) 
     'file_type' => string '' (length=0) 
     'file_path' => string './images/pictures/' (length=18) 
     'full_path' => string './images/pictures/' (length=18) 
     'raw_name' => string '' (length=0) 
     'orig_name' => string '' (length=0) 
     'client_name' => string '' (length=0) 
     'file_ext' => string '' (length=0) 
     'file_size' => string '' (length=0) 
     'is_image' => boolean false 
     'image_width' => string '' (length=0) 
     'image_height' => string '' (length=0) 
     'image_type' => string '' (length=0) 
     'image_size_str' => string '' (length=0) 

무엇이 문제 일 수 있냐?

+0

어떻게 실패 하는가? 무슨 일이야? 오류가 있습니까? – kba

+0

아무런 오류가 없습니다. 그냥 var_dump를로드합니다 ... 컨트롤러를 확인하십시오. 업로드에 실패하면 var_dump를로드하고 그렇지 않으면 리디렉션합니다. ;/ –

+0

'$ this-> upload-> do_upload()'를 두 번하고 있습니다. – kba

답변

0

$config['upload_path'] = './images/pictures/'; 작성하는 경로가 올바른지, 파일을 쓸 수있는 적절한 권한이 있는지 확인하십시오.

또한 Kristian이 쓴대로 $this->upload->do_upload(); 업로드 부분을 두 번하고 있습니다.

오류를 확인하려면, 당신은이 작업을 수행 할 수 있습니다

<?php 
if(!$this->upload->do_upload())   
{ 
    echo $this->upload->display_error(); 
    return FALSE; 
} 
else 
{ 
    $data = $this->upload->data(); 
    return TRUE; 
} 
+0

오, 그래, 나도 알아, 그건 그냥 오류를 제공하는지 확인하는 것이지만, 그렇지 않다. 로컬 호스트에있는 경우 두 번 확인해 보겠습니다. http : // localhost/images/pictures/전체 부분을 wrtie 할 수 있습니까? 또한 localhost에서 확인하면 사용 권한을 설정해야합니까? –

+0

테스트 할 때마다 권한을 설정해야합니다. 간단히 당신은 CI 프로젝트의 메인 폴더에'uploads' 폴더를 만들고 권한을 설정하고 다시 시도 할 수 있습니다. –

+0

흠, 이제 어떻게 localhost에 대한 권한을 설정할 수 있습니까? : P Windows 7을 사용하고 있는데 localhost에 서버 설정이 없으므로 서버를 설정하고 filezilla를 통해 연결해야합니까? –

관련 문제