<?php if($this->input->post('submit')) { if(!empty($_FILES["product_image"]['name'])) { $config = array( 'upload_path' => "./uploads/products/", 'allowed_types' => "jpg|jpeg|png|gif", 'overwrite' => TRUE, 'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb) //'max_height' => "768", //'max_width' => "1024", 'file_name' => time().'-'.$_FILES["product_image"]['name'] ); $uploaderror = ''; $this->load->library('upload', $config); if($this->upload->do_upload('product_image')) { $uploadData = array('upload_data' => $this->upload->data()); $uploadedfilename = $uploadData['upload_data']['file_name']; } else { $uploaderror = $this->upload->display_errors(); } } } ?>