Welcome Guest, Not a member yet? Register   Sign In
(fixed)$this->load->library('upload', $config); do not return upload data?
#1

[eluser]mortenfrisi[/eluser]
My controller to upload a image and a thumb:

Code:
if ($this->input->post('upload'))
            {                  
                $filname = "img".md5(uniqid($this->input->ip_address() , TRUE));
                $gallery_path = realpath(APPPATH . '../profile_img/');
                              
                // Uploading the normale image
                $config['file_name'] = $filname;
                $config['overwrite'] = false;
                $config['upload_path'] = $gallery_path;
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size']    = '200';
                $config['max_width']  = '1024';
                $config['max_height']  = '768';
                $this->load->library('upload', $config);  
                $this->upload->do_upload();
                // added the line above, since I can not use $this->upload->data() else?
                // now the image is being uploaded twice  
                $image_data = $this->upload->data();                          
                
                // making a thumb
                $configthumb['image_library'] = 'gd2';
                $configthumb['source_image']  = $image_data['full_path'];
                $configthumb['create_thumb']   = TRUE;
                $configthumb['maintain_ratio'] = TRUE;
                $configthumb['width']          = 200;
                $configthumb['height']          = 150;
                $this->load->library('image_lib', $configthumb);
                $this->image_lib->resize();
                
                
                    if (!$this->upload->do_upload() OR !$this->image_lib->resize())
                    {
                        $message = array('message' => $this->upload->display_errors());
                        $message = array('message' => $this->image_lib->display_errors());
                        $this->load->view('dashboard_view', $message);
                    }
                    else
                    {
                        $message = array('message' => "Your profilepicture has been uploaded",  
                                         'message_profilepicture' => $image_data['raw_name'],
                                         'message_profilepicture_ext' => $image_data['file_ext']);
                        $this->load->view('dashboard_view', $message);                      
                    }
            }      
            else
            {
                $this->load->view('dashboard_view');
            }

The problem is that this uploads the image twice, plus a thumb.

If I remove the $this->upload->do_upload(); it still uploads the image (only one), but then I am not able to use the $this->upload->data() function. Should I not be able to use this function?


fix: this line is wrong and creates the 2nd upload:
Code:
if (!$this->upload->do_upload() OR !$this->image_lib->resize())
:red:




Theme © iAndrew 2016 - Forum software by © MyBB