[eluser]invision[/eluser]
OK, I think I'm getting there.
It submits and sends the email, but
doesn't attach the file.
When I submit the form I get this message on the page:
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: id
Filename: controllers/vacancies.php
Line Number: 60
You did not select a file to upload.
success!
My
Controller:
Code:
function apply(){
$slug = $this->input->post('slug');
$data['page_data'] = $this->MPages->getPageBySlug('vacancies');
//$data['page_data'] = $this->MVacancies->getVacancyItem($slug);
//$data['page_data'] or redirect('vacancies/');
$data['title'] = $data['page_data']['title'];
$data['body'] = $data['page_data']['body'];
if(isset($_FILES['file']['name'])) {
$email = '[email protected]';
$file_name = $this->do_upload(); // _do_upload() should return the path and name of the uploaded file
$this->email->attach($file_name);
$message = "$email has applied for this job.";
$this->email->from($email, '[email protected]');
$this->email->to('[email protected]');
$this->email->subject('Application for Job #' . $id);
$this->email->message($message);
$this->email->send();
$this->load->view('form_success');
} else {
$data['main'] = 'vacancies_apply';
$this->load->vars($data);
$this->load->view('template');
}
}
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
Thanks again for all your help, I think we're nearly there.