[eluser]E303[/eluser]
I have been trying to work this out for some time. When I go to upload a file I get this error:
A PHP Error was encountered
Severity: Warning
Message: Illegal offset type in isset or empty
Filename: libraries/Upload.php
Line Number: 138
The Controller:
Code:
function For_Sale_add()
{
$this->load->model('admin/Admin_Model');
$this->load->model('Admin_Model');
// File Upload
$config['upload_path'] = './images/forsale/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2000';
$config['max_width'] = '300';
$config['max-height'] = '300';
$this->load->library('upload');
$this->upload->initialize($config);
$forsaleimage = $this->upload->data();
$this->upload->do_upload($forsaleimage);
$this->Admin_Model->ForSale_add();
$data['query'] = $this->Admin_Model->Flakes_navigation();
$this->load->view('admin/main_admin_view', $data);
}
The Model:
Code:
function ForSale_add()
{
$file = $this->upload->data();
$data = array(
'title' => $_POST['title'],
'body' => $_POST['body'],
'image' => $file['file_name']
);
$this->db->insert('for_sale', $data);
}
The Form
Code:
<?=form_open_multipart('main_admin/For_Sale_add');?>
<br />
<fieldset>
<label>Item Title:</label>
<input type="text" name="title" />
<p>
<label>Description:</label><br />
<textarea name="body" id="ajaxfilemanager" cols="70" rows="20"></textarea>
</p>
<label>Image:</label>
<input type="file" name="userfile" /><br />
<em>Max size: 300 x 300. Max file size: 2000kb</em>
</fieldset>
<br />
<input type="submit" value="Save" class="flake_submit"/>
<?=form_close();?>
Any ideas why?