Upload image error when hosting - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Upload image error when hosting (/showthread.php?tid=52796) |
Upload image error when hosting - El Forum - 06-27-2012 [eluser]Unknown[/eluser] Dear All, I am a new developer who prefer in CodeInitor. I am using codeIgnitor 2.1.0. I am a problem with upload file when it is hosting online. //upload image public function img_upload_file() { $sizes = array(500); //upload $config['upload_path'] = './images/' . $this->session->userdata('use_username') . '/'; $config['max_size'] = 50000000; //kb $config['allowed_types'] = 'gif|jpg|jpeg|png|bmp|tiff'; $this->load->library('upload', $config); $this->session->set_userdata('upload', $config['upload_path']); $i = 0; //upload image if ($this->upload->do_upload('userfile')) { $filename = $this->upload->data(); $this->session->set_userdata("filename", $this->session->userdata('use_username') . $filename['file_name']); $oldw = $filename['image_width']; $oldh = $filename['image_height']; foreach ($sizes as $size) { //resize $neww = 0; $newh = 0; $i++; $config['image_library'] = 'gd2'; $config['source_image'] = './images/' . $this->session->userdata('use_username') . '/' . $filename['file_name']; $config['create_thumb'] = false; $config['maintain_ratio'] = TRUE; $config['new_image'] = './images/' . $this->session->userdata('use_username') . '/' . $this->session->userdata('use_username') . $filename['file_name']; if ($oldw >= $size && $oldw > $oldh) { $neww = $size; $newh = ($neww * $oldh) / $oldw; } else if ($oldh >= $size && $oldh > $oldw) {//if width <= height $newh = $size; $neww = ($newh * $oldw) / $oldh; } else {//if widht or height < $size $neww = $oldw; $newh = $oldh; } $config['width'] = $neww; $config['height'] = $newh; $this->image_lib->clear(); $this->image_lib->initialize($config); $this->image_lib->resize(); unlink('images/' . $this->session->userdata('use_username') . '/' . $filename['file_name']); } return true; } else { return false; } } thanks, Math Man Upload image error when hosting - El Forum - 06-27-2012 [eluser]Sanjay Sarvaiya[/eluser] unset $config variable after Image upload success. Code: ... |