CodeIgniter Forums
Upload... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Upload... (/thread-22283.html)



Upload... - El Forum - 09-03-2009

[eluser]danielbertini[/eluser]
Hello all.
I have the function upload:

Code:
function upload(){
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']  = '10000';
        $config['max_width']  = '2000';
        $config['max_height']  = '2000';
        $config['encrypt_name'] = TRUE;
        $config['remove_spaces'] = TRUE;
        $this->load->library('upload', $config);
        if (!$this->upload->do_upload()){
            echo "error";
        }
        else{
            $data = array('upload_data' => $this->upload->data());
            $upload_data = $this->upload->data();
            $width = $upload_data['image_width'] ;
            $height = $upload_data['image_height'];
            $config['image_library'] = 'gd';
            $config['source_image'] = './uploads/'.$upload_data['file_name'];
            $config['maintain_ratio'] = FALSE;
            $config['quality'] = 100;
            if($height>$width){
                $config['x_axis'] = 0;
                $config['y_axis'] = ($height-$width)/2;
                $config['height'] = $width;
                $config['width'] = $width;
            }
            else{
                $config['y_axis'] = 0;
                $config['x_axis'] = ($width-$height)/2;
                $config['height'] = $height;
                $config['width'] = $height;
            }
            $this->load->library('image_lib', $config);
            $this->image_lib->crop();
            $config['maintain_ratio'] = FALSE;
            $config['height'] = 60;
            $config['width'] = 60;
            $this->image_lib->initialize($config);
            $this->image_lib->resize();    
        }
    }

Function upload work but dont resize or crop just only upload...
Using Leopard + Mamp + http://valums.com/ajax-upload/
In phpinfo GD library is active, and i use captcha without problems...

Any help?
thanks!


Upload... - El Forum - 09-03-2009

[eluser]pistolPete[/eluser]
Do you get any error messages? Enable logging.

You should also call

Code:
$this->image_lib->clear();

User guide:
Quote:The clear function resets all of the values used when processing an image. You will want to call this if you are processing images in a loop.



Upload... - El Forum - 09-03-2009

[eluser]BrianDHall[/eluser]
You might also try this out on a regular image you upload with hard-coded address, and maybe you can whittle-down where the problem is a bit better.

From the manual it recommends:

Code:
if ( ! $this->image_lib->resize())
{
    echo $this->image_lib->display_errors();
}

...to display errors.