upload 라이브러리를 사용할 때
# controller/image
<?php
class Image extends CI_Controller {
public function index() {
$this->load->view('upload_v');
}
public function upload_file() {
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$config['upload_path'] = './uploads/';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
// 펑션(input의 name)
if ($this->upload->do_upload('thumb_image')) {
print_r($this->upload->data());
} else {
print_r($this->upload->display_errors());
}
}
}
do_upload()
의 변수에는 input 파일의 name을 쓴다.
# views/imageupload_v.php
<form action="image/uploadimage" class="shake" id="contactForm" name="contact-form" method="post" enctype="multipart/form-data">
<input class="form-control" type="file" name="thumb_image" />
<input class="btn" type="submit" type="submit" value="Upload" />
</form>
</body>