After uploading a single image with its original size, I can save that image both in the folder and DB.
Now I want to resize the same image into multiple dimensions while uploading. I don't know how to do this. Here is my code
Controller:
$newpath = './img/Pics/'.$user_id;
if (!is_dir($newpath)){
mkdir($newpath, 0777);
}
$config['upload_path'] = $newpath;
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf';
$config['overwrite'] = TRUE;
$config['max_width'] = '256';
$config['max_height'] = '256';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$field_name ="reg_pic";
$rgpic="0";
if (!$this->upload->do_upload($field_name)) {
$error = $this->upload->display_errors();
$data['error']=$error;
}
else {
$data = $this->upload->data();
$regpicname= $user_id.'/'.$data['file_name'];
$rgpic="1";
}
if ($rgpic!=0) {
$data = array(
'reg_image'=>$regpicname
);
}
Please help me to solve this.