Welcome Guest, Not a member yet? Register   Sign In
Strange ! $this->upload->do_upload skip condition
#1

i found it strange see the code and i will explain below:
Model
Code:
public function _my_upload(
$upload_path,
$seo_name = null,
$max_width = null,
$max_height = null,
$types = null,
$max_size = null,
$overwrite = null
){
    $date = date("m-d-Y");
   $config['upload_path']   = $upload_path;
   $config['allowed_types'] = $types ?? 'gif|jpg|png|jpeg';
   $config['max_size']      = $max_size ?? 2048;
   $config['max_width']     = $max_width ?? 1080;
   $config['max_height']    = $max_height ?? 1080;
   $config['file_name']     = $seo_name .'_'. $date .'-'. time();
   $config['overwrite']     = $overwrite ?? true;
            
   $this->upload->initialize($config);
            
   return $config;
}

Controller
Code:
$config = $this->My_upload->_my_upload(
    $this->upload_path,
   $ucfirst_name,
   1700,
   1000
);

if ( ! $this->upload->do_upload('add_slide'))
{
   $error = ['error' => $this->upload->display_errors()];
   $this->session->set_flashdata('show', '1');
}
else
{
   $image_arr      = ['sl_image' => $this->upload->data('orig_name')];
                    
   $data_merge     = array_merge($data, $image_arr);
                    
   $get_prev_image = $this->General_model->get_select_once('sl_image', $id, $this->tbl_slide);
                    
   if($get_prev_image != '' && file_exists($this->path.$get_prev_image))
   { unlink($this->path.$get_prev_image); }
                    
   $error = ['error' => "Fail to update data: ID {$id}."];
   $this->session->set_flashdata('show', '1');
   if($this->General_model->general_update($data_merge, $id, $this->tbl_slide))
   {
       $affect_result = $this->db->affected_rows();
       $error = ['error' => "({$affect_result})Rows has been update successfully."];
       $this->session->set_flashdata('show', '0');
   }
}
when i test upload image with jpg and file is under 2MB it upload and appear message Successfully and file is upload to my folder,

but when i test upload image file that bigger than 2MB it skip my condition If (! $this->upload->do_upload) and return else condition. Huh

that is strange to me. everything is ok just i can't return specific error message of upload.
current CI: 3.1.6
Reply
#2

Did you check your server's file upload limit?
Reply
#3

These settings are in the php.ini file.


// Form post size
post_max_size=128M

// Upload file size
upload_max_filesize=128M

These should both be set to the same value.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(This post was last modified: 01-10-2018, 08:00 PM by tereaksmey123.)

yes after set 128M in localhost it show error message Thank.
Reply
#5

You can change the size to what ever you need, that is just an example size.

Set it to the size of the file you need to upload.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB