Sending a file via form to email with Laravel (Localhost)

前端 未结 1 1216
故里飘歌
故里飘歌 2021-01-13 03:41

Newbie to Laravel so be kind lol

My config for mail.php is correct and emails are being received successfully for text inputs to gmail, but not sure exactly how to

相关标签:
1条回答
  • 2021-01-13 04:33

    First off, be sure to allow your file to accept file uploads:

    {{ Form::open(array('url' => '/form', 'files' => true)) }}
    

    After that, you can do something along the lines of this:

    $input = Input::all();
    Mail::send('emails.welcome', $data, function($message) use ($input)
    {
        $message->to('mail@domain.net');
        $message->subject('Welcome to Laravel');
        $message->from('sender@domain.net');
        $message->attach($input['resume']->getRealPath(), array(
            'as' => 'resume.' . $input['resume']->getClientOriginalExtension(), 
            'mime' => $input['resume']->getMimeType())
        );
    });
    

    Documentation: http://laravel.com/docs/requests#files and http://laravel.com/docs/mail#basic-usage

    0 讨论(0)
提交回复
热议问题