Hi,
I have a form which has 5 file input fields, all works fine with my CRUD methods if the file field is not empty, however the client now wants to set some of the fields to be non mandatory.
This is how I am trying to do it in my code, the problem I am encountering is declaring a null variable(to insert a blank value in the respective database field) if the file field is empty. I get an undefined variable message from codeigniter when nothing is uploaded...
This is the code that code checks if a file has been uploaded or not.
if(isset($_FILES['ticketing_summary_file']))
{
$this->upload->initialize($config);
if($this->upload->do_upload('ticketing_summary_file'))
{
$upload_data=$this->upload->data();
$ticketing_summary_file_name=$upload_data['file_name'];
$ticketing_summary_full_file_path = $path_to_uploads.'/'.$ticketing_summary_file_name;
$show['ticketing_summary_file_url'] = $ticketing_summary_full_file_path;
}
}
if(!isset($_FILES['ticketing_summary_file']))
{
$show['ticketing_summary_file_url'] = $empty_file_message;
}
Then this is how I insert the data into my database... I have tried declaring the contents of 'ticketing_summary_file' in the code below and above, but it says its empty either way
$show = array('tour_id' =>$tour,
'date' => $this->input->post('date'),
'location' => $location);
$id = $this->show_model->save($show);
Cheers for any help,
Dan