2014-04-16 5 views
2

gallery.php -보기CodeIgniter : 이미지가 업로드되지 않습니다.

<!DOCTYPE HTML> 
    <html lang="en-US"> 
    <head> 
     <title>CI Gallery</title> 
    </head> 
    <body> 


     <div id="upload"> 
      <?php 
      $this->load->helper("form"); 
      echo form_open_multipart('gallery/up'); 
      ?> 
      <input type="file" name="file"> 
      <?php 
      echo form_submit('upload','Upload'); 
      echo form_close(); 
      ?>  
     </div> 
    </body> 
    </html> 

gallery.php 컨트롤러이 내 코딩 파일입니다

<?php 
class Gallery extends CI_Controller { 

    function index() 
    { 
     $this->load->view('gallery'); 

    } 

    function up() 
    { 
      $config['upload_path'] = './images/'; 
      $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
      $config['max_size'] = '1000000'; 
      $config['max_width'] = '10240'; 
      $config['max_height'] = '7680'; 
      $this->load->library('upload',$config); 
      $this->upload->do_upload('file'); 
      $this->load->view('gallery'); 
    } 


} 

. 여기서 파일이 업로드되지 않습니다. 누군가 도와주세요. 라이브러리 업로드가로드되지 않아 작동이 멈춘다 고 느낍니다. 그것이 문제를 해결하는 방법이 문제라면. 당신의 HTML에서

답변

0

을 쓸 수 있습니다, 문제는 이미지를 업로드 할 수 있었다 폴더를 기록 할 권한이 없다고, 그래서 해당 폴더를 쓰기 가능했다 이제는 잘 작동합니다.

0

추가 양식 태그

<form enctype="multipart/form-data" name="" action=""></form> 
+1

그는 form 태그를 가지고 있습니다. form_open_multipart입니까? – Albzi

+0

@BeatAlex, 예, 건설적인 것이 아닙니다. – SagarPPanchal

0

코드는 오류없이 좋은 것 같다. 이미지 업로드 여부가 경로 문제 일 수 있는지 아래 코드를 시도해보십시오. 코드 아래의 복사 및 컨트롤러의 당신의 업 기능에

"$this->load->view('gallery');" 

이 이상했습니다.

if (! $this->upload->do_upload()) 
{ 
    $error = array('error' = $this->upload->display_errors()); 

// uploading failed. $error will holds the errors. 
} 
else 
{ 
    $data = array('upload_data' => $this->upload->data()); 

// uploading successfull, now do your further actions 
} 
0

당신이 업로드 이미지 서버 측 코드

function do_upload() 
    { 
     $config['upload_path'] = './uploads/'; 
     $config['allowed_types'] = 'gif|jpg|png'; 
     $config['max_size'] = '100'; 
     $config['max_width'] = '1024'; 
     $config['max_height'] = '768'; 

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

     if (! $this->upload->do_upload()) 
     { 
      $error = array('error' => $this->upload->display_errors()); 

      print_r($error); //debug it here 

     } 
     else 
     { 
      $data = array('upload_data' => $this->upload->data()); 

      $this->load->view('upload_success', $data); 
     } 
    } 
관련 문제