我有这段代码可以将两个图像上传到文件夹“ / uploads”
如何将2号图像上传到另一个文件夹?
代码
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|svg' ;
$config['max_size'] = 2048;
$this->load->library('upload',$config);
if (! $this->upload->do_upload('userfile') && !$this->upload->do_upload('userfile2') ) {
$errors = array('error' => $this->upload->display_errors());
$post_image= 'noimage.png' ;
$post_image2= 'noimage.png' ;
} else {
$data = array('upload_data' => $this->upload->data()) ;
$post_image= $_FILES['userfile']['name'];
$post_image2= $_FILES['userfile2']['name'];
}
$this->post_model->create_post($post_image,$post_image2);
redirect('../');
答案 0 :(得分:1)
使用不同的$ config路径再次加载库:
$this->load->library('upload', $config1);
然后上传
$this->load->library('upload', $config2);
另一条带有另一条路径的上传文件。
您也可以使用initialize($config)