Skip to content
Advertisement

Sending mail with no required attachment Laravel 8

I’m working on a project in Laravel 8. I make a contact form that will be sent to my email address and contains name, email, message and attachment. Name, email and message are required but no attachment. When I send the form completely filled in (name, email, message and attachment) everything works fine and the message comes to my email address (attachment too) But if I fill in only the name, email, message and attachment I leave blank it will print an error:

JavaScript

I need the message to be sent without an attached attachment.

Code:

contact_us_blade.php:

JavaScript

contact_email.blade.php

JavaScript

EmailController.php:

JavaScript

Mail.php:

JavaScript

Advertisement

Answer

Conditionally attach the image?

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement