I have a codeigniter app and everytime you go to the page, it says you did not select a file to upload. I’m using the same codeigniter function for the page display as the file handle upload.
I’m using ajax to submit the form so I can’t check the $_SERVER[‘REQUEST_METHOD’]
Here’s a snippet of my function:
if(!$this->upload->do_upload('userFile')) { // if there are errors uploading the file of if it's the first time on the page…
$content_data['album'] = $album;
echo "post go through?";
// if the $_POST array is not empty display the error. That means that someone submitted the form without choosing a file
//if(isset($_POST['submit'])) {
$content_data['error'] = array('error' => $this->upload->display_errors());
//}
$content_data['data'] = array('upload_data'=>$this->upload->data());
$data['sess'] = $this->session;
$data['content'] = $this->load->view('member/addPhoto', $content_data, true);
$this->load->view('template/admin', $data);
} else { // else there were no errors and we can resize and upload.
}
You can check whether it is submitted or not before doing the above operation