×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
File Field
Mekalb
Fresh Boarder
Posts: 8
9 Jahre 9 Monate her #657
von Mekalb
File Field wurde erstellt von Mekalb
Hi,
I have created a single table component using several fields, including the J_file field. When a form is submitted, the controller calls a basic mailing script in the model, which emails the contents of the form to a predefined address.
Everything works fine, except for adding the uploaded file (I'll call it "presentation") as an attachment. I have tried simply passing the form data to the model, and assigning the value of presentation as an attachment, but that doesn't work. When I print the value of presentation I can see that it gives me something like C:\fakepath\filename.jpg, so it stores the location of the file, but it is neither the actual location, nor the actual name (after the MD5 stuff is added) of the file.
I am obviously not doing it correctly, so I have two questions -
How do I add the file which was just uploaded as an attachment?
Where is the code which adds the datestamp MD5 to the filename?
I have added my mail script for clarity.Thanks in advance.
I have created a single table component using several fields, including the J_file field. When a form is submitted, the controller calls a basic mailing script in the model, which emails the contents of the form to a predefined address.
Everything works fine, except for adding the uploaded file (I'll call it "presentation") as an attachment. I have tried simply passing the form data to the model, and assigning the value of presentation as an attachment, but that doesn't work. When I print the value of presentation I can see that it gives me something like C:\fakepath\filename.jpg, so it stores the location of the file, but it is neither the actual location, nor the actual name (after the MD5 stuff is added) of the file.
I am obviously not doing it correctly, so I have two questions -
How do I add the file which was just uploaded as an attachment?
Where is the code which adds the datestamp MD5 to the filename?
I have added my mail script for clarity.
/**
* Script to send an email with each application attached
**/
// Grab the mail object
$mailer = JFactory::getMailer();
// Set the sender
$config = JFactory::getConfig();
$sender = array(
$config->get( 'config.mailfrom' ),
$config->get( 'config.fromname' )
);
$mailer->setSender($sender);
// Set the recipient
$mailer->addRecipient('email@email.com');
// Content of the body
$body = "Here are all the other fields";
$presentation = $data['presentation']
$mailer->setSubject('Automated Email');
$mailer->setBody($body);
$mailer->addAttachment($presentation); //<--- Not correct.
// Send the email
$send = $mailer->Send();
if ( $send !== true ) {
return false;
} else {
return true;
}
Bitte Anmelden oder Registrieren um der Konversation beizutreten.
Ladezeit der Seite: 0.044 Sekunden