mardi 9 octobre 2018

Laravel 5.6: Call to a member function getRealPath() on string

I am trying to send an email with a file in my project in Laravel, but I am getting this error Call to a member function getRealPath() on string This is my store function:

public function store(Request $request)
{     
    $data = array(
       'destino'    => $request['destino'],
       'asunto'     => $request['asunto'],
       'contenido'  => $request['contenido'],
       'a_file'     => $request['a_file']
    );

    Mail::send('administracion.email.email_body', $data, function($message) use ($data)
    {

        $message->to($data['destino']);
        $message->subject($data['asunto']);
        $message->from(Config::get('mail.username'));

        $message->attach($data['a_file']->getRealPath(), array(
        'as'    => 'a_file' . $data['a_file']->getClientOriginalExtension(),
        'mime'  => $data['a_file']->getMimeType()) 
        );
    });

    return Redirect::to('email');

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire