Welcome Guest, Not a member yet? Register   Sign In
Image Crop not working.
#6

[eluser]sb05[/eluser]
thanks a lot Mat-MooSmile
it's not that I should read/write my code more carefully, it's that I'm still new at PHP and Codeigniter, but I'm a step closer now. So the image crop worked, but a new problem has arisen.
Now when I upload my image I get a white page with the cropped image at the top left. But the same URL should have displayed my site again where the cropped image is in the left column as an Ad image.
So have I placed the code in the wrong place? First I tried to add the code in my do_upload function of my model. But that didnt work. But it did work in my controller.

Here is my new 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';  
          

          

            $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;
                        }
$this->load->library("image_moo");
      $this->image_moo->load($full_file_path)
            ->resize_crop(100,100)
            ->save_dynamic();
      if($this->image_moo->errors) print $this->image_moo->display_errors();

            
        // 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);    }

So as you can see. My /addad url should have loaded some views, but now it only displays the cropped image.
Should I make a new variable that contains the new cropped image? Did I put the code in the right place?


Messages In This Thread
Image Crop not working. - by El Forum - 01-20-2011, 04:53 AM
Image Crop not working. - by El Forum - 01-20-2011, 06:05 AM
Image Crop not working. - by El Forum - 01-20-2011, 07:13 AM
Image Crop not working. - by El Forum - 01-20-2011, 08:09 AM
Image Crop not working. - by El Forum - 01-20-2011, 01:11 PM
Image Crop not working. - by El Forum - 01-20-2011, 02:42 PM
Image Crop not working. - by El Forum - 01-20-2011, 02:56 PM
Image Crop not working. - by El Forum - 01-20-2011, 05:00 PM
Image Crop not working. - by El Forum - 01-21-2011, 07:54 AM
Image Crop not working. - by El Forum - 01-21-2011, 12:36 PM
Image Crop not working. - by El Forum - 01-22-2011, 06:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB