本文整理汇总了PHP中ContactForm::uploadAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactForm::uploadAttachment方法的具体用法?PHP ContactForm::uploadAttachment怎么用?PHP ContactForm::uploadAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactForm
的用法示例。
在下文中一共展示了ContactForm::uploadAttachment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: contactAction
public function contactAction(array $params)
{
//creating form entity
$form = new ContactForm($_POST);
//check if we have a flash message in get params
$flash_msg = isset($params['flash_msg']) ? $params['flash_msg'] : '';
//if form sent
if ($_POST) {
if ($form->validate()) {
$flash_msg = 'Message sent';
$email_body = "This is a message from {$form->getName()}, {$form->getEmail()} : {$form->getMessage()}";
//C:\xampp\mailoutput
mail('kap0sha@yandex.ru', 'Contact message', $email_body);
if ($_FILES['attachment']) {
$form->uploadAttachment();
}
} else {
$flash_msg = 'Fill in the fields';
}
//redirectt
header("Location: /index.php?controller=index&action=contact&flash_msg={$flash_msg}");
}
$data = array('form' => $form, 'message' => $flash_msg);
return $this->render('contact', $data);
}