Welcome Guest, Not a member yet? Register   Sign In
How to re-size image when uploading to my website?
#1

[eluser]scm22ri[/eluser]
Hi Everyone,

I'm attempting to re-size an image during the upload to my website. I'm having a difficult time doing this. I believe my problem is the path. I believe I have to get the image path for this to work (please tell me other wise if I'm incorrect). Below is my syntax. When I attempt to upload an image, that's working fine but it's the re-sizing that's being me a problem. What am I doing wrong? Any help would be appreciated. Thanks.


Code:
function image_resize(){
  
   $config['image_library'] = 'gd2';
   $config['source_image'] = $upload_path['full_path'];
      $config['maintain_ratio'] = TRUE;
      $config['width']  = 100;
      $config['height'] = 50;

      $this->load->library('image_lib',$config);
      $this->image_lib->resize();
}

function do_upload(){
  
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '1000';
  $config['max_width']  = '10224';
  $config['max_height']  = '7668';

  $this->load->library('upload', $config);

  if (!$this->upload->do_upload()){
  
   $error = array('error' => $this->upload->display_errors());
   $this->load->view('view_your_car2', $error);
  
  } else {
   $upload_path = './uploads/'.$image;
   $this->image_resize();
   $data = array('upload_data' => $this->upload->data());
   $this->load->view('upload_success', $data);
  }
}




Theme © iAndrew 2016 - Forum software by © MyBB