[eluser]E303[/eluser]
Thanks for that.. Now I just get on error
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined index: file_name
Filename: admin/admin_model.php
Line Number: 234
Code:
function exhibitionsAddDB()
{
// dont need this line
// $picture = $_FILES['userfile'];
$url = url_title($_POST['title']);
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->upload->initialize($config);
// dont pass in the value of userfile, do_upload retrieves the value of
// userfile by default if no parameters are passed in.
// If you pass in a paramter it looks for that field name in the post data
// instead of userfile.
// ALSO do upload only returns true or false if it succeded or not, not the file!
if ( ! $this->upload->do_upload())
{
$error = $this->upload->display_errors();
echo $error;
return;
}
else
{
$file_data = array('upload_data' => $this->upload->data());
$data = array(
'title' => $_POST['title'],
'description' => $_POST['body'],
'date' => $_POST['date'],
'endDate' => $_POST['enddate'],
'artistId' => $_POST['artist'],
'url' => $url,
'picture' => $file_data['file_name'],
);
$this->db->insert('exhibitions', $data);
}
}
Also when I look in the uploads file I don't see the file so I guess it doesn't get uploaded?