Controller:
public function sendemail(Request $request)
{
$data = array(
'name'=> $request->name,
'email'=> $request->email,
'text'=> $request->text,
'category'=> $request->category,
'company'=> $request->company,
'number'=> $request->number
);
\Mail::send('AltHr/Portal/supportemail', $data, function ($message) use($data){
$message->from($data['email'], $data['name']);
$message->to('ra7veer@gmail.com')->subject($data['company'] . ' - ' .$data['category']);
$message->attach($request->file('files')->getRealPath(), [
'as' => $request->file('files')->getClientOriginalName(),
'mime' => $request->file('files')->getMimeType()
]);
});
return view('AltHr.Portal.support');
}
Blade:
<div class="form-group form-group-default">
<label>Attachment</label>
<input type="file" name="files[]" accept="file_extension|image/*|media_type" multiple>
</div>
I tried doing a simple contact form to send to my email. Currently it works im able to send that email but without attachments. So i tried doing the code for the attachments but it dont seem to be working im getting error:
Undefined variable: request
What am I doing wrong here?