I need to rename image name after upload because my requirement is I need to add id with it so it's possible after store image name in DB.
I have done code for uploading image with and without watermark into different folder but now I want to change it's name like:
$imageName = $imgId.''.randomstring.''.$ext;
I have tried with below code but same image stored in both folder with watermark. I want to store original image in original_image folder and with watermark image in watermark_folder. Please help me to resolve this issue.
$getImgs = $this->photographer_model->get_uploaded_image($result);
                    $getExt = substr($getImgs[0]['img_name'], strrpos($getImgs[0]['img_name'],'.')+0);
                    $randomStr = $this->generate_random_string(20);
                    $fileName  = $result."-".$randomStr."".$getExt;
                    $originalImgPath  = base_url()."assets/original_image/".$fileName;
                    $watermarkImgPath = base_url()."assets/watermark_image/".$fileName;
                    $uploadOrgImg   = 'assets/original_image/'.$fileName;
                    $uploadWaterImg = 'assets/watermark_image/'.$fileName;
                    $updateImg = $this->photographer_model->update_img_path($result, $fileName, $originalImgPath, $watermarkImgPath);
                    if(file_exists('assets/original_image/'.$getImgs[0]['img_name']) || file_exists('assets/watermark_image/'.$getImgs[0]['img_name'])) {
                        unlink('assets/original_image/'.$getImgs[0]['img_name']);
                        unlink('assets/watermark_image/'.$getImgs[0]['img_name']);
                        $config1['upload_path']   = 'assets/original_image/'; 
                        $config1['allowed_types'] = 'jpeg|png|jpg|svg';
                        $config1['file_name']     = $fileName; // set the name here
                        $this->load->library('upload', $config1);
                        $this->upload->initialize($config1);
                        $this->upload->do_upload('image');
                        $config['upload_path']   = 'assets/watermark_image/'; 
                        $config['allowed_types'] = 'jpeg|png|jpg|svg';
                        $config['file_name']     = $fileName; // set the name here
                        $this->load->library('upload', $config);
                        $this->upload->initialize($config);
                        $this->upload->do_upload('image');
                    }