我想上传多个带有codeigniter的文件,其要求如下:
有人可以帮助我吗?
先谢谢。
答案 0 :(得分:0)
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1024*10';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data=$this->upload->data();
$this->thumb($data,700,false);
$this->thumb($data,100,true);
unlink($data['full_path']);
$this->load->view('upload_success', $data);
}
}
function thumb($data,$thumb_size,$create_thumb)
{
$config['image_library'] = 'gd2';
$config['source_image'] =$data['full_path'];
$config['create_thumb'] = $create_thumb;
$config['maintain_ratio'] = TRUE;
$config['width'] = $thumb;
$config['height'] = $thumb;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
供参考[此处]:http://www.tutsmore.com/tutorials/codeigniter-image-upload-with-mysql/