[eluser]adamck[/eluser]
You can save the Upload success or upload fail to a flashdata session and then do $this->index();
This will run the index() function after you have set the flashdata.
Then in your view, you can have a section to see if the flashdata is not empty and display the flashdata contents.
Code:
if (! $this->upload->do_upload())
{
$this->session->set_flashdata('error', $this->upload->display_errors());
$this->index();
}
else
{
$this->session->set_flashdata('success', 'File Uploaded');
// ADD TO DB HERE
$this->index();
}
When your index loads the view, the flashdata will exist for that 1 instance, when you refresh it will have gone.
Code:
<?php if(!empty($this->session->flashdata('success')
{
echo $this->session->flashdata('success');
}
else if(!empty($this->session->flashdata('error')
{
echo $this->session->flashdata('error');
}
?>
Also... you dont need to pass the username to the view in order to display it, just put the code directly into your view...
Code:
<?php echo $this->session->userdata('username'); ?>