You Did not select a file to upload.But the image is uploaded

Wednesday, November 4, 2015

I found so many questions with this same error . But those answers did not clear my error and still the error remains



when i try to upload image . this error comes




" You Did not select a file to upload "




But the image is uploaded in the correct location ..



Controller



class image extends CI_Controller {

function __construct() {
parent::__construct();

$this->load->helper(array('form', 'url'));

$this->load->library('session');

$this->load->library('layout');

$this->load->model('admin_m');

$this->load->library('upload');

}

function projects_more() {

$config['upload_path'] = './uploads/';

$config['allowed_types'] = 'gif|jpg|png';

$config['max_size'] = '100000';

$config['max_width'] = '102400';

$config['max_height'] = '76800';


$this->load->library('upload', $config);

$this->upload->initialize($config);

if (!$this->upload->do_upload('photo')) {

$error = array('error' => $this->upload->display_errors());

$this->layout->view('home_page', $error);

} else {

$data = array('upload_data' => $this->upload->data());
$data1 = $this->upload->data();
$image = $data1['file_name'];
$project = $this->input->post('project');


$content= $this->input->post('content');

$this->admin_m->projects_more($image,$project,$content);
redirect('image/projects_more');

}
}
}


My view page



projects1.php



<?php echo form_open_multipart('image/projects_more'); ?>

<table>

<tr>

<td><input type="file" name="photo" id="photo" size="20"></td>

</tr>

</table>

<input type="submit" name="submit" value="Submit">

<?php echo form_close(); ?>

0 comments:

Post a Comment