Reputation: 1451
Error is : You did not select a file to upload.
My controller:
$image_name=$_FILES['screen_img']['name'];
$config['upload_path']=FCPATH.'asset/project_images/';
$config['allowed_types']='jpeg|jpg|png';
$config['overwrite']=true;
$config['max_size']="2048000";
$config['file_name']=$image_name;
$config['max_height']="768";
$config['max_width']="1024";
$this->load->library('upload');
$this->upload->initialize($config);
if(!$this->upload->do_upload($image_name))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
$this->load->view('screen/new_screen', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($data);
$this->load->view('screen/new_screen',$data);
}
My view
<?php echo form_open_multipart('screen/new_screen')?>
<input type="file" class="form-control" name="screen_img" /><br>
<input type="submit" class="btn btn-success" name="submit" value="submit">
<?php echo form_close();?>
I was try all examples of internet but they did not work. I can not find issue.
Upvotes: 0
Views: 39
Reputation:
You need to write field name in do_upload function
if(!$this->upload->do_upload("screen_img"))
instead of $_FILES['screen_img']['name'];
Upvotes: 1