Post_plot.php (This is my view form)
<form action="http://localhost:8080/ci/admin/plot/do_upload" enctype="multipart/form-data" method="post">
<input type="text" name="property_title" value="" />
<input type="file" name="img" id="plot-img" value="" />
<input type="submit" name="submit" value="Submit" />
</form>
I have a long form with an image upload option.
I am using do_upload function to upload file
I am getting following error
Array ( [name] => a.jpg [type] => image/jpeg [tmp_name] => C:\xampp\tmp\phpBD75.tmp [error] => 0 [size] => 132277 ) Array ( [error] =>
You did not select a file to upload.
)
Plot.php Controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Plot extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('Admin_layout');
$this->load->model('admin/plot_model');
$this->config->load('plot_rules');
$this->output->enable_profiler(TRUE);
}
public function do_upload()
{
$config['upload_path'] = '../images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($img))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());
//$this->load->view('upload_success', $data);
print_r($data);
}
}//do_upload
}//class
Should i pass any parameters in do_upload function?