[eluser]amina[/eluser]
Hi, I have a function multiple resize. My problem is that upload the first and the second resize.
My class:
Code:
class Uploads {
private $CI;
private $name;
function __construct($param = array()){
$this->CI =& get_instance();
$this->name = $param['name'];
}
function do_upload_image() {
if (!empty($_FILES['userfile']['name'])){
$config['upload_path'] = IMAGE_UPLOAD_PATH;
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name'] = $this->name;
$config['max_size'] = '5000';
$config['max_width'] = '2024';
$config['max_height'] = '1768';
$this->CI->load->library('upload',$config);
if (!$this->CI->upload->do_upload('userfile'))
return array('error' => $this->CI->upload->display_errors());
else
return array('upload_data' => $this->CI->upload->data());
$imgpath = $this->CI->upload->upload_path.$this->CI->upload->file_name;
$config = array(
'image_library' => 'GD2',
'source_image' => $imgpath,
'create_thumb' => TRUE,
'maintain_ratio' =>FALSE,
'height' => 80,
'width' => 100
);
$this->CI->load->library('image_lib',$config);
if (!$this->CI->image_lib->resize())
return array('error' => $this->image_lib->display_errors());
else
return array('upload_data' => $this->CI->upload->data());
$config = array(
'create_thumb' => FALSE,
'maintain_ratio'=> FALSE,
'width' => 425,
'height' => 318
);
$this->CI->image_lib->initialize($config);
if (!$this->CI->image_lib->resize())
return array('error' => $this->image_lib->display_errors());
else
return array('upload_data' => $this->CI->upload->data());
$config = array(
'create_thumb' => FALSE,
'maintain_ratio'=> FALSE,
'width' => 130,
'height' => 170
);
$this->CI->image_lib->initialize($config);
if (!$this->CI->image_lib->resize())
return array('error' => $this->image_lib->display_errors());
else
return array('upload_data' => $this->CI->upload->data());
$config = array(
'create_thumb' => FALSE,
'maintain_ratio'=> FALSE,
'width' =>70 ,
'height' => 55
);
$this->CI->image_lib->initialize($config);
if (!$this->CI->image_lib->resize())
return array('error' => $this->image_lib->display_errors());
else
return array('upload_data' => $this->CI->upload->data());
}
}
Thanks!