jeudi 24 mai 2018

Why Laravel 5 mail, I attached a .tmp file?

I am trying to attach a file in an email that is sent from a form, the problem is that the file is coming to me .tmp

My Controller

public function choiceAnalyst(Request $request){

$userSelect = $request->input('user');
$data = User::where('id', '=', $userSelect)->first();
$data->attach = $request->file('document')->getRealPath();

Mail::to('eaquino@spi.com.ve')->send(new AnalystMonth($data));

return redirect()->route('home', ['message' => 'Correo enviado correctamente']);
}

My Class

class AnalystMonth extends Mailable

{
    use Queueable, SerializesModels;

public $user;

/**
 * Create a new message instance.
 *
 * @return void
 */
public function __construct(User $user)
{
    $this->user = $user;

}

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->view('mails.analystMonth')->attach($this->user->attach);
}
}

I think I got .tmp by the getRealPath() method that I include when I pick up the file, but I'm not sure. How do I get my file to reach the .tmp extension?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire