Welcome Guest, Not a member yet? Register   Sign In
how i can resize two image .in one source
#1

[eluser]Unknown[/eluser]
Hello. I'm Iranian and my language is not good.
And all of the text have a Google translation
how i can resize two image .in one source
for example i write this code.

controller

Code:
<?php
class Gallery extends Controller
{
    
    function Gallery()
    {
        parent::Controller();
        $this->load->model('gallery_model');
    }
    function index()
    {
        $data['title']='gallery';
        $this->load->view('admin/gallery_view',$data);
    }
    function insert()
    {
        $config['upload_path']='./uploads/';
        $config['allowed_types']='png|jpg|gif';
        $config['max_size']='1024';
        $this->load->library('upload',$config);
        if(!$this->upload->do_upload('photo1') or !$this->upload->do_upload('photo2'))
        {
            $data['errors']=$this->upload->display_errors();
            $data['title']='error';
            $this->load->view('admin/gallery_view',$data);
        
        }
        
        else{
        $data=array('upload_data'=>$this->upload->data());
        $data=$data['upload_data']['file_name'];
        
        $data2=array('upload_data2'=>$this->upload->data());
        $data2=$data2['upload_data2']['file_name'];
        
        
        $thumb='t_'.$data;
        $config['image_library']='GD2';
        $config['source_image']='./uploads/'.$data;
        $config['new_image']='./uploads/gallery/thumb/'.$thumb;
        $config['create_thumb']=false;
        $config['maintain_ratio']=false;
        $config['width']=150;
        $config['height']=150;
        $this->load->library('image_lib',$config);
        $this->image_lib->resize();
        $this->image_lib->clear();
        
        $thumb2='mt_'.$data2;
        $config['image_library']='GD2';
        $config['source_image']='./uploads/'.$data2;
        $config['new_image']='./uploads/gallery/'.$thumb2;
        $config['create_thumb']=false;
        $config['maintain_ratio']=true;
        $config['width']=650;
        $config['height']=450;
        $this->load->library('image_lib',$config);
        $this->image_lib->resize();
        
        if(!$this->image_lib->resize())
        
        {
        $data['errors']= $this->image_lib->display_errors();
        $this->load->view('admin/gallery_view',$data);
    
        }
        
        else
        {
        
        
    
        $this->load->view('admin/gallery_view');    
    }
    }
        }
    

    
}
#2

[eluser]jedd[/eluser]
Hi mohsen and welcome to the CI forums.

What is going wrong with this code that you have posted here?

It is easier for us if you describe:
a) what you are trying to do
b) what you have done so far
c) what you expect will happen
d) what actually happens (or 'what goes wrong')

You have done 75% - which is great - but the last bit is the most important!




Theme © iAndrew 2016 - Forum software by © MyBB