Image uploading code in Codeigniter

// Code for approve
		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();
				}
			}

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>