There really is a much easier way of doing this:
if ($this->upload->do_upload()) // If file was uploaded
{
$data = $this->upload->data(); // Returns information about your uploaded file.
$thumbnail = $data['raw_name'].'_thumb'.$data['file_ext']; // Here it is
}
$config['upload_path'] = './web_assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000KB';
$config['overwrite'] = FALSE;
$config['encrypt_name'] = TRUE;
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
$this->upload->do_upload($se);
$imagedata = $this->upload->data();
//print_r($imagedata);
//echo $imagedata['file_name'];
echo $this->upload->display_errors('<p>', '</p>');
$config['image_library'] = 'gd2';
$config['source_image'] = '/web_assets/uploads/'.$imagedata['file_name'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 300;
$config['height'] = 500;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$thumbnail = '/web_assets/uploads/'.$imagedata['raw_name'].'_thumb'.$imagedata['file_ext']; // Here it is;
0 comments:
Post a Comment