codeigniter - uploading file issue, error not displaying -


i trying restrict file size when user uploads. have following function:

function do_upload()     {         $config['upload_path']   = './uploads/';                 $config['allowed_types'] = 'gif|jpg|png|jpeg';         $config['max_size'] = '50';         //$config['max_width'] = '1024';         //$config['max_height'] = '768';          $this->load->library('upload', $config);         $fullimagepath;         if (isset($_files['userfile']) && !empty($_files['userfile']['name']))         {               if (! $this->upload->do_upload('userfile'))               {                    $error = array('file_error' => $this->upload->display_errors());                    //print_r($error);                     $this->load->view('layout/header');                    $this->load->view('register', $error);                    $this->load->view('layout/footer');                }else{                   // set $_post value 'image' can use later                   $upload_data    = $this->upload->data();                   $fullimagepath = '/uploads/' . $upload_data['file_name'];                }         }                //path of image on server         return $fullimagepath;     } 

if print $error array above, shows error file large, want. problem if don't print it, whole process completed if picture big, , data in database complete. how can fix this?

your return outside of else. want:

return $fullimagepath;

to underneath

$fullimagepath = '/uploads/' . $upload_data['file_name'];

otherwise return regardless of whether it's errored or not, i'm guessing sent database..?


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -