email()->validate('user-email'); // check for errors if ($validator->hasErrors()) { $_SESSION['errors']['cv-submission-form'] = $validator->getAllErrors(); } else { /* Send email with attached file(s) */ $path = ROOT . '/file-uploads/'; $attachments = array(); if (isset($_POST['cv']) && !empty($_POST['cv'])) { $cv = FileUploader::getPostedFiles($_POST['cv']); foreach ($cv as $f) { $attachments[] = $path . $f['file']; } $attachments = implode(', ', $attachments); } $email_config = array( 'sender_email' => 'contact@phpformbuilder.pro', 'sender_name' => 'Php Form Builder', 'recipient_email' => addslashes($_POST['user-email']), 'subject' => 'Php Form Builder - CV Submission Form', 'attachments' => $attachments, 'filter_values' => 'cv-submission-form, cv' ); $sent_message = Form::sendMail($email_config); Form::clear('cv-submission-form'); } } /* ================================================== The Form ================================================== */ $form = new Form('cv-submission-form', 'horizontal', 'novalidate', 'material'); // $form->setMode('development'); // materialize plugin $form->addPlugin('materialize', '#cv-submission-form'); $form->setCols(3, 9); $form->startFieldset('CV Submission'); $form->addHtml('
'); $form->addIcon('user-name', '', 'before'); $form->addInput('text', 'user-name', '', 'Name', 'required'); $form->addIcon('user-first-name', '', 'before'); $form->addInput('text', 'user-first-name', '', 'Firstname', 'required'); $form->addIcon('user-email', '', 'before'); $form->addInput('email', 'user-email', '', 'Email', 'required'); $form->addInput('text', 'position-applying-for', '', 'Position Applying For'); $form->addPlugin('tinymce', '#additional-information', 'contact-config'); $form->addTextarea('additional-information', '', 'Additional Information'); $form->addHelper('3 files max. Accepted File Types : .pdf, .doc[x], .xls[x], .txt', 'cv'); // reload the previously posted file if the form was posted with errors $current_file = ''; if (isset($_POST['cv']) && !empty($_POST['cv'])) { $posted_file = FileUploader::getPostedFiles($_POST['cv']); $current_file_path = ROOT . '/file-uploads/'; $current_file_name = $posted_file[0]['file']; if (file_exists($current_file_path . $current_file_name)) { $current_file_size = filesize($current_file_path . $current_file_name); $current_file_type = mime_content_type($current_file_path . $current_file_name); $current_file = array( 'name' => $current_file_name, 'size' => $current_file_size, 'type' => $current_file_type, 'file' => '/file-uploads/' . $current_file_name, // url of the file 'data' => array( 'listProps' => array( 'file' => $current_file_name ) ) ); } } $fileUpload_config = array( 'upload_dir' => '../../../../../file-uploads/', // the directory to upload the files. relative to phpformbuilder/plugins/fileuploader/default/php/ajax_upload_file.php 'limit' => 3, // max. number of files 'file_max_size' => 2, // each file's maximal size in MB {null, Number} 'extensions' => ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt'], 'debug' => true // log the result in the browser's console and shows an error text on the page if the uploader fails to parse the json result. ); $form->addFileUpload('file', 'cv', '', 'Upload your CV