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

File Field

9 yıl 10 ay önce #657 Yazan: Mekalb
File Field, Mekalb tarafından oluşturuldu
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.

Lütfen sohbete katılmak için Giriş ya da Hesap açın.

Sayfa oluşturma süresi: 0.045 saniye
Geliştiren: Kunena Forum