[eluser]Unknown[/eluser]
I get this error when I try to upload a file that doesn't meet the file requirements in the "upload config". i.e., wrong file type, too large, etc. When the file meets all the requirements, everything is fine. When it doesn't meet the requirements, I'm expecting to get the error info from the upload class, but instead I get a fatal error.
Code:
Fatal error: Call to a member function load() on a non-object in ... on line 770
My code:
Code:
function update() {
$this->load->library('upload');
$upload_fields = array ();
// this is a predefined array that holds field options
foreach($this->field_options as $field => $field_option) {
if(sizeof($field_option['upload']) > 0) {
$upload_fields[] = $field;
}
}
// if there are upload fields for this table
if(sizeof($upload_fields) > 0) {
// loop through them
foreach($upload_fields as $file_upload) {
// check to see if there's an upload
if(isset($_FILES[$file_upload]) && $_FILES[$file_upload]['size'] > 0) {
// initialize the upload library
$this->upload->initialize($this->field_options[$file_upload]['upload']);
// if successful upload
if ($this->upload->do_upload($file_upload)) {
// print out upload data
echo "<pre>".print_r($this->upload->data(), 1)."</pre>";
} else {
// print out error info
echo "<pre>".print_r($this->upload->display_errors(), 1)."</pre>";
}
}
}
}