Hi everyone,
I am trying to make a CV upload tool...
function UploadCV() {
// Create fields
$fields = new FieldSet(
new TextField('Name', 'Name'),
new EmailField('Email', 'Email'),
new TextField('Telephone','Telephone / Mobile'),
new FileField('CVUpload', 'CV Attachment')
);
// Create action
$actions = new FieldSet(
new FormAction('SendContactForm', 'UPLOAD & SEND')
);
// Create Validators
$validator = new RequiredFields('Name', 'Email', 'Telephone');
return new Form($this, 'UploadCV', $fields, $actions, $validator);
}
function SendContactForm($data, $form) {
//Set data
$From = $data['Email'];
$To = "lawrence@newedge.co.uk";
$Subject = "CV Upload Submission";
$email = new Email($From, $To, $Subject);
//set template
$email->setTemplate('CvUpload');
//populate template
$email->populateTemplate($data);
//attach upload
if (isset($_FILES["CVUpload"]) && is_uploaded_file($_FILES["CVUpload"]["tmp_name"])) {
$email->attachFile($_FILES["CVUpload"]["tmp_name"], $_FILES["CVUpload"]["name"]);
}
//send mail
$email->send();
//return to submitted message
Director::redirect($this->Link("?success=1"));
}
public function Success()
{
return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
}
However when I select a .docx file I get this error....
[Notice] Undefined index: docx
POST /candidates/UploadCV
Line 451 in /var/sites/s/seimansears.co.uk/public_html/sapphire/email/Mailer.php
Source
442 }
443
444 /*
445 * Get mime type based on extension
446 */
447 function getMimeType($filename) {
448 global $global_mimetypes;
449 if(!$global_mimetypes) loadMimeTypes();
450 $ext = strtolower(substr($filename,strrpos($filename,'.')+1));
451 return $global_mimetypes[$ext];
452 }
453
454 /*
455 * Load the mime-type data from the system file
456 */
457 function loadMimeTypes() {
Trace
getMimeType(ecommerce questions.docx)
Line 389 of Mailer.php
encodeFileForEmail(Array)
Line 116 of Mailer.php
htmlEmail(lawrence@newedge.co.uk,lawrence@newedge.co.uk,CV Upload Submission,<html> <body> <p>The following message was submitted to your site by <a href="mailto:lawrence@newedge.co.uk">lawrence howlett:</a></p> <p>Name: lawrence howlett</P> <p>Email: lawrence@newedge.co.uk</P> <p>Telephone / Mobile: 448707606812</P> </body> </html>,Array,Array,,)
Line 31 of Mailer.php
Mailer->sendHTML(lawrence@newedge.co.uk,lawrence@newedge.co.uk,CV Upload Submission,<html> <body> <p>The following message was submitted to your site by <a href="mailto:lawrence@newedge.co.uk">lawrence howlett:</a></p> <p>Name: lawrence howlett</P> <p>Email: lawrence@newedge.co.uk</P> <p>Telephone / Mobile: 448707606812</P> </body> </html>,Array,Array,)
Line 486 of Email.php
Email->send()
Line 111 of Page.php
Page_Controller->SendContactForm(Array,Form,SS_HTTPRequest)
Line 329 of Form.php
Form->httpSubmission(SS_HTTPRequest)
Line 143 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
Line 161 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
Line 147 of Controller.php
Controller->handleRequest(SS_HTTPRequest)
Line 199 of ContentController.php
ContentController->handleRequest(SS_HTTPRequest)
Line 67 of ModelAsController.php
ModelAsController->handleRequest(SS_HTTPRequest)
Line 282 of Director.php
Director::handleRequest(SS_HTTPRequest,Session)
Line 125 of Director.php
Director::direct(/candidates/UploadCV)
Line 127 of main.php
I have done some searching around and cant find any answers... does anyone know how to fix this issue?
Thanks!