Welcome Guest, Not a member yet? Register   Sign In
Function stopped working!
#1

[eluser]wakey[/eluser]
Hi everyone,

Been getting to grips with codeigniter the last few weeks and made some good progress. Tonight I was working on a function to upload an image, resize the image and make a thumbnail of the image. It was working perfectly and then for some reason it stopped working and I can't work out what I've done wrong.

If anyone could have a look over and point out the error it'd be much appreciated as I can't see it.

Code:
function upload()
        {
            $config['upload_path'] = './gallery/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size']    = '0';
            $config['max_width']  = '0';
            $config['max_height']  = '0';
            $config['encrypt_name'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            
            $this->load->library('upload', $config);
            
        
            if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());
                
                redirect('add-location');
            }
            
            else
            {        
            
                   $configThumb = array();  
                   $configThumb['image_library'] = 'gd2';
                   $configThumb['new_image'] = './gallery/thumbs/';
                   $configThumb['source_image'] = '';  
                   $configThumb['create_thumb'] = TRUE;  
                   $configThumb['maintain_ratio'] = TRUE;
                   $configThumb['quality'] = '70%';
                   $configThumb['width'] = 100;  
                   $configThumb['height'] = 100;
                  
                  
                  
                $data = array('upload_data' => $this->upload->data());
                
                  $up_data = $this->upload->data();
                  $config2 = array();  
                  $config2['image_library'] = 'gd2';
                  $config2['source_image'] = '';
                  $config2['quality'] = '100%';
                  $config2['maintain_ratio'] = TRUE;
                if( ( $up_data['image_width'] > 500 ) || ( $up_data['image_height'] > 333 ) ) {
                    if( $up_data['image_width'] > $up_data['image_height'] ) {
                        $ratio = ($up_data['image_width'] / $up_data['image_height']);
                        $config2['height'] = 333;
                        $config2['width'] = 500 * $ratio;
                    } else {
                        $ratio = ($up_data['image_height'] / $up_data['image_width']);
                        $config2['width'] = 500;
                        $config2['height'] = 333 * $ratio;
                    }
                }
        
                
                $img_data = $this->upload->data();                
                
                   $file_name = $img_data['file_name'];
                
                $thumb_ext = $img_data['file_ext'];
                $thumb_path = $img_data['raw_name'];
                
                $config2['source_image'] = $img_data['full_path'];
                $configThumb['source_image'] = $img_data['full_path'];
                
                $this->load->library('image_lib');
                
                $this->image_lib->initialize($config2);
                 $this->image_lib->resize();
              
                  $this->image_lib->initialize($configThumb);
                $this->image_lib->resize();
                
                $this->load->model('upload_model');
            
                $query = $this->upload_model->upload($file_name,$thumb_path,$thumb_ext);                
                
                if ($query)
                {
                
                    $data['main_content'] = 'add-success';
                    $data['tab'] = 'view';
                    $data['page'] = 'Location Successfully Added';
                    //$data['test'] = $file_name;
                    
                    $this->load->view('template', $data);
                }
            }
        }

I am receiving no error messages, the page is white as if it can't load.

It is definitely uploading the first image to the gallery image but then it is getting stuck in the else statement.

I appreciate any help. Thanks.


Messages In This Thread
Function stopped working! - by El Forum - 01-07-2010, 04:38 PM
Function stopped working! - by El Forum - 01-07-2010, 04:54 PM
Function stopped working! - by El Forum - 01-07-2010, 10:46 PM
Function stopped working! - by El Forum - 01-08-2010, 03:44 AM
Function stopped working! - by El Forum - 01-08-2010, 11:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB