Looks like a permissions issue. Have you checked the permissions of the file and make sure the Laravel application has what it needs to read it?
Aug 31, 2016
8
Level 5
Unable to open file for reading - Swift_IoException
Hello everyone, I'm trying to send a email using attach as is show in the documentation, with s3 files attached works fine, but if a change to local storage I get the error :
Swift_IoException
Unable to open file for reading
to use local follow the recomendation to make the symbolic link and the local files display but it doesn't attach using this command:
ln -sr public/storage storage/app/public
Here is my controller
public function sendEmailLab($paciente,$carpeta,$archivo){
$parametros = Parametro::first();
$pac = Paciente::where('id_pac','=',$paciente)->first();
$path = Storage::url("almacenamiento/$carpeta/$archivo");
Mail::send('email.laboratorio',['title'=>$parametros->laboratorio_cabecera,
'content'=>$parametros->laboratorio_detalle], function($message) use ($parametros, $path,$pac) {
$message->to($pac->correo_pac);
$message->subject($parametros->laboratorio_cabecera);
$message->attach($path);
});
return back();;
}
The view is just calling the method
<td>
<a href="{{ url('carpetas',array($pac->id_pac,$directorio->nombre, $archivo->nombre,'mail')) }}" class="btn btn-default"><span class="glyphicon glyphicon-envelope" aria-hidden="true"></span></a>
</td>
Please give a tip
Greetings
Level 5
I made some changes in my controller to solve it, I don't know if there is a better solution but until then I put my solution here.
public function sendEmailLab($paciente,$carpeta,$archivo){
$parametros = Parametro::first();
$pac = Paciente::where('id_pac','=',$paciente)->first();
//s3-public validation
if (config('filesystems.default') == 'public'){
$path =realpath("storage/almacenamiento/".$carpeta."/".$archivo);
}else {
$path = Storage::url("almacenamiento/$carpeta/$archivo");
}
Mail::send('email.laboratorio',['title'=>$parametros->laboratorio_cabecera,
'content'=>$parametros->laboratorio_detalle], function($message) use ($parametros, $path,$pac) {
$message->to($pac->correo_pac);
$message->subject($parametros->laboratorio_cabecera);
$message->attach($path);
});
return back();;
}
Thaks for your replies
1 like
Please or to participate in this conversation.