2012-12-29 4 views
-3

다음 코드를 작성했지만 작동하지 않습니다.codeigniter로 파일을 업로드하는 방법은 무엇입니까?

$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); 
     $this->upload->do_upload('product_image'); 

HTML 양식 : 당신이 준

1)

<body> 
    <form method="post" action="localhost/codeigniter/index.php/product/insert" enctype="multipart/form-data"> 
    <label>Product Name :</label> <input type="text" name="product_name"/><br/> 
    <label>Product Image :</label> <input type="file" name="product_image"/><br/> 
    <input type="submit" name="submit" value="Submit"/> 
    <?php echo validation_errors(); ?> 
    </form> 
</body> 
+3

당신이지고 어떤 오류 :이 코드 양식 Repalce

? 우리에게도 귀하의 HTML 양식을 보여주십시오 – GBD

+0

우리에게 더 많은 정보를 제공해주십시오. 어떤 오류가 발생 했습니까? – RezaSh

+0

오류가 발생하지 않습니다. 파일이 업로드되지 않았습니다. –

답변

3

당신이 쓴 잘못된 HTML 양식; 양식 작업 속성 다음의 양식.

2) 양식 태그 앞에 body 태그를 닫았습니다.

3) 사용 된 절대 경로.

<body> 
    <form method="post" action="<?php echo base_url();?>product/insert" enctype="multipart/form-data"> 
    <label>Product Name :</label> <input type="text" name="product_name"/><br/> 
    <label>Product Image :</label> <input type="file" name="product_image"/><br/> 
    <input type="submit" name="submit" value="Submit"/> 
    <?php echo validation_errors(); ?> 
    </form> 
</body> 
+0

어디에서 '업로드'폴더를 배치해야합니까? –

+0

@DigmaChauhan은 appliction 폴더와 시스템 폴더가 – sandip

+0

인 'uploads'폴더에 파일이 업로드되지 않은 동일한 레벨에 있습니다. 그리고 어떤 오류도 발생하지 않습니다. –

관련 문제