Does anyone with knowledge of OpenCart 2.0.1.1 know how I could implement the following addAttachment function found in system/libary/mail.php:
public function addAttachment($filename) {
$this->attachments[] = $filename;
}
into catalog/controller/information/contact.php - so that the default contact form can also include an attachment upload feature? I tried this but no dice.
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
unset($this->session->data['captcha']);
$mail = new Mail($this->config->get('config_mail'));
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
$mail->setSubject(sprintf($this->language->get('email_subject'), $this->request->post['name']));
$mail->setText(strip_tags($this->request->post['enquiry']));
$mail->addAttachment($this->request->post['file']);
$mail->send();
$this->response->redirect($this->url->link('information/contact/success'));
}
You can not directly pass file to
$mail->addAttachment($this->request->post['file']);
First you need to upload file
Now we need upload script to upload file
Finally now you can pass attachment file to mail function