× Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues

File Field

pred 9 rokmi 8 mesiacmi #657 od Mekalb
File Field bolo vytvorené 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.
       /**
      *   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;
      }
Thanks in advance.

Prosím Prihlásiť alebo Registrácia pre zdieľanie konverzácie.

Čas vytvorenia stránky: 0.044 sekúnd
Funguje na Kunena fórum

We use cookies so that you can place orders and we can provide a better service. You can control the use of cookies at the individual browser level. If you reject cookies, you may still use our website, but your ability to use some features or areas of our website may be limited.