$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