[eluser]LuckyFella73[/eluser]
Maybe it's not nessesary to upload to a temp direction first.
If the whole validation process fails and you delete the uploaded
file anyway there is no big difference between deleting the file
from a temp directory or the "real" directory.
What I do in my callback function:
Code:
// config stuff here
if ( ! $this->upload->do_upload() )
{
$this->form_validation->set_message('__do_upload_logo', $this->upload->display_errors());
return FALSE;
}
else
{
$filedata = $this->upload->data();
$this->name_uploaded_file = $filedata['file_name'];
return TRUE;
}
And in the code section where the validation failed:
Code:
if ($this->form_validation->run() == FALSE)
{
if ( file_exists($this->upload_path.$this->name_uploaded_file) AND strlen($this->name_uploaded_file)>1 )
{
unlink($this->upload_path.$this->name_uploaded_file);
}
$this->load->view(get_class($this).'/your_form.php', $data);
}
$this->upload_path is defined in my class constructor