[eluser]jake142[/eluser]
Hi,
Im new to codeigniter (and new to php). How can I check if there is a file to upload, befor I do the actual upload? The $this->input->post('userfile')!="" doesn't work.
Code:
if($this->input->post('userfile')!="")
{
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('header');
$this->load->view('ads/error', $error);
$this->load->view('right_side');
$this->load->view('footer');
}
else
{
$data = array('upload_data' => $this->upload->data());
$upload_data = $data['upload_data'];
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_data['full_path'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 300;
$config['height'] = 300;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
$imagename = $upload_data['file_name'];
$contenttype = $upload_data['file_type'];
}
}
else
{
//Just store some information in db and use default file (always uploaded)
}
Any help is very appritiated.
Thanks!