Welcome Guest, Not a member yet? Register   Sign In
Creating Thumbnails
#1

[eluser]Sein Kraft[/eluser]
Hi I'm new in codeigniter. First sorry about my english T_T.

I can't do work the creation of thumbnails. Anyone can help me?

Code:
<?php

class Upload extends Controller
{
    
    function Upload()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
    }
    
    function index()
    {    
        $this->load->view('upload_form', array('error' => ' ' ));
    }

    function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '2048'; //2 MB
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
            
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            $this->load->view('upload_form', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            
            $config['image_library'] = 'GD2';
            $config['source_image'] = './uploads/'.$upload_data['file_name'];
            $config['maintain_ratio'] = TRUE;
            $config['create_thumb'] = TRUE;
            $config['height'] = '150';
            $config['width'] = '150';
        
            $this->load->library('image_lib', $config);
            $this->image_lib->resize();
            
            $this->load->view('upload_success', $data);
        }
            
    }
}
?>
#2

[eluser]Chris Newton[/eluser]
1. Can you successfully upload files.

2. Do you have the GD2 Library installed on your server?
#3

[eluser]Sein Kraft[/eluser]
Yes I have. Now its working =)

Thanks ^^
Code:
<?php

class Upload extends Controller
{
    
    function Upload()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
    }
    
    function index()
    {    
        $this->load->view('upload_form', array('error' => ' ' ));
    }

    function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '2048'; //2 MB
        $config['max_width']  = '1600';
        $config['max_height']  = '1200';
            
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            $this->load->view('upload_form', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            $temp=$this->upload->data();
            
            $config['image_library'] = 'GD2';
            $config['source_image'] = './uploads/'.$temp['file_name'];
            $config['maintain_ratio'] = TRUE;
            $config['create_thumb'] = TRUE;
            $config['quality'] = '100';
            $config['height'] = '150';
            $config['width'] = '150';
        
            $this->load->library('image_lib', $config);
            $this->image_lib->resize();
            
            $this->load->view('upload_success', $data);
        }
            
    }
}
?>




Theme © iAndrew 2016 - Forum software by © MyBB