RossUK
111
1
Laravel

Attach file on contact form

Posted 4 months ago by RossUK

Can any one give me quick and simple example of how to include a file attachment on a contact form please?

Here is my existing controller method

lass ContactController extends Controller
{
    public function store(Request $request) 
    {

        $this->validate($request, [
            'name' => 'required',
            'email' => 'required',
            'subject' => 'required',
            'phone' => 'required',
            'message' => 'required',
            // 'g-recaptcha-response' => 'required|recaptcha',
        ]);

    Mail::to(env('WEBEMAILRECIPIENT',''))->send(new ContactForm($request));
    Mail::to($request->email)->send(new ContactFormConfirmation($request));

    return redirect()->back()->with('message', 'form submitted');

    }
}

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.