$this->load->library('image_lib');
if (!empty($_FILES['advert_image'])) {
$filename = substr(md5(time()), 0, 28) . strrchr($_FILES['advert_image']['name'], '.');
$config['upload_path'] = 'public/events/images/';
$config['allowed_types'] = 'jpg|jpeg|png|JPG|JPEG|PNG|BMP|bmp|gif|GIF';
$config['file_name'] = $filename;
$config['is_image'] = true;
$this->load->library('upload', $config);
$this->upload->initialize($config);
//$this->upload->do_upload('advert_image');
//start resize image
if (!$this->upload->do_upload('advert_image')) {
echo "error" . count;
} else {
$image_data = $this->upload->data();
$configer = array(
'image_library' => 'gd2',
'source_image' => $image_data['full_path'],
'maintain_ratio' => TRUE,
'width' => 480,
'height' => 480,
);
$this->image_lib->clear();
$this->image_lib->initialize($configer);
$this->image_lib->resize();
}
//end resize
$profile_pic = isset($filename) ? $filename : "";
}
添加您的代码并解释您在这样做时面临的问题。 –
您是否收到错误?你没有给我们太多的信息来在这里工作。 – flauntster
欢迎使用堆栈溢出。你已经尝试过这么做了吗?请回顾[预计需要多少研究工作?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users)。堆栈溢出不是一种编码服务。您需要研究您的问题,并尝试在发布之前亲自编写代码。如果遇到某些特定问题,请返回并包含[最小,完整和可验证示例](https://stackoverflow.com/help/mcve)以及您尝试的内容摘要,以便我们提供帮助。 – Sand