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

File Field

9 años 9 meses antes #657 por Mekalb
File Field Publicado por 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.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Tiempo de carga de la página: 0.049 segundos
Gracias a Foro Kunena

Utilizamos cookies propias y de terceros para mejorar nuestros servicios y mostrarle publicidad relacionada con sus preferencias mediante el análisis de sus hábitos de navegación. Si continua navegando, consideramos que acepta su uso.