我正在尝试在电子邮件中显示从LARAVEL传输的图像(在我的Web应用程序中上传)。
收到的电子邮件的图片:
当前,我实现了将图像显示为电子邮件的附件,但是我的目标是将图像显示为电子邮件的封面照片。电子邮件的内容在catalogEmail.blade.php文件中开发。
CatalogController.pho
function Sendcatalog (Request $request, $url){
$this->validate($request, [
'email' => 'required|email'
]);
$language=Language::where('url', '=', $url)->first();
if(count($language)==0){
abort(404);
}
$emailStorage= new EmailStorage;
$emailStorage -> email = $request -> input('email');
$emailStorage->save();
$catalog=Catalog::first();
$data = array(
'email' => $request->email,
'filename' => $catalog->file_name,
'title' => $catalog->title,
'content' => $catalog->content,
'post_thumbnail' => $catalog->post_thumbnail,
'post_thumbnail2' => $catalog->post_thumbnail2,
);
$visitorEmail=$request->email;
Mail::to('kajoswiss@gmail.com')->send(new SendCatalogInfo($data));
Mail::to($visitorEmail)->send(new SendCatalog($data));
return back()->with('successPost', 'You will get soon catalog on your email address');
}
Web.php
Route::post('/sendcatalog/{url}', 'CatalogController@Sendcatalog')->name('catalog.send');
SendCatalog.php(mail.php)
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendCatalog extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('kajoswiss@gmail.com')->subject('KAJO company')->attach(public_path('uploads/catalogs/pictures/'. $this->data['post_thumbnail2']))->view('email/catalogEmail')->with('data', $this->data);
}
}
CatalogEmail.blade.php
<h3>Hello, catalog {{ $data['title'] }}</h3>
<p>Hello, catalog {!! $data['contnet'] !!}</p>
<img src="{{public_path('uploads/catalogs/pictures/'.$data['post_thumbnail2'])}}"/>
Preuzmite katalog iz linka
<a href="{{asset('storage/upload/'.$data['filename'])}}" class="btn btn-hot text-capitalize btn-xs" download>Preuzmi fajl</a>
答案 0 :(得分:1)
您必须在tdl之前添加图像源地址。像这样:
<img src="http://example.com/{{public_path('uploads/catalogs/pictures/'.$data['post_thumbnail2'])}}"/>