[eluser]sb05[/eluser]
Ok, I tried the image_moo library, but I'm stuck at the same problem. The simple fact is, it's not picking up the methods, because I am also not getting the error messages on display. So I must be placing the code in the wrong place??
I put the code in my upload function, because I want the uploaded images to be cropped, right? But it's not working not the image_lib nor the image_moo library gets activated.
Here is my model:
Code:
function do_upload() {
$this->gallery_path = realpath(APPPATH . '../ad_images');
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->gallery_path,
'max_size' => 200000,
'maintain_ration' => true,
'width' => 100000,
'height' => 100000,
'x_axis'=> 100,
'y_axis'=> 100
// $config['x_axis'] = '100';
//$config['y_axis'] = '100';
);
$this->load->library('upload', $config);
if (!$this->upload->do_upload('image_url')){
$error = $this->upload->display_errors();
echo $error;
}
$upload_data = $this->upload->data();
$file_name=$upload_data['image_url'];
$full_file_path = $path_to_uploads.'/'.$file_name;
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
if ( ! $this->image_lib->crop())
{
echo $this->image_lib->display_errors();
}
$this->load->library("image_moo");
if($this->image_moo->errors)
print $this->image_moo->display_errors();
$this->image_moo->load('image_url')
->resize(100,100)
->save_dynamic();
}
}
?>
And here is my Controller:
[code]
function addAd(){
// set common properties
$data['title'] = 'Add new ad';
$data['action'] = site_url('ads/addAd');
$data['link_back'] = anchor('ads','Back to list of ads',array('class'=>'back'));
// set validation properties
$this->_set_fields();
$this->_set_rules();
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '10000';
$config['max_width'] = '1000000';
$config['max_height'] = '10000000';
$config['upload_path'] = './ad_images';
$config['x_axis'] = '100';
$config['y_axis'] = '100';
$path_to_uploads='./ad_images';
// $config['upload_path'] = $path_to_uploads;
$this->load->library('upload', $config);
if (!$this->upload->do_upload()){
$error = $this->upload->display_errors();
echo $error;
}else{
$upload_data=$this->upload->data();
$file_name=$upload_data['file_name'];
$full_file_path = $path_to_uploads.'/'.$file_name;
}
// run validation
if ($this->validation->run() == TRUE){
$data['message'] = 'It is not going to the database';
}else{
// save data
$ad = array('name' => $this->input->post('name'),
'image_url' => $full_file_path,
'link' => $this->input->post('link'),
'client_name' => $this->input->post('client_name'))
;
$ad_id = $this->adModel->save($ad);
// set form input name="id"
$this->validation->ad_id = $ad_id;
// set user message
$data['message'] = '<div class="success">add new ad success</div>';
}
$data['ads'] = $this->adModel->get_by_id($ad_id)->row();
// load viewinclude 'person.php';
$this->load->view('banner_view', $data);
$this->load->view('left_column_view', $data);
$this->load->view('right_column_view', $data);
$this->load->view('adEdit', $data);
$this->load->view('footer_view', $data); }
Please help