2017-12-27 997 views
0

我想然而,存储在[存储/程序/证明]将图像附加到电子邮件,我越来越重视形象...如何从存储在邮件Laravel

mail_attach

代替图像文件,这是我迄今为止所做的。

控制器

 $user->accType = "TBC"; 
     //stored as "proof/img_name.jpg" in DB 
     $user->proofLink = request()->file('proofFile')->store('proof'); 
     $user->save(); 
     \Mail::to('[email protected]')->send(new ConfirmAccount($user)); 

ConfirmAccount.php enter image description here

我在做什么错?

+0

给文件的mimtype了。 –

回答

0

该错误实际上是由不完整路径引起的。

$location = storage_path("app/$user->proofLink");

是返回 “应用程序/”,而不是 “应用程序/记录/ img_name.jpg”。

为了解决这个问题,我编辑ConfirmAccount.php如下:

public function __construct(User $user) 
{ 
    $this->URL = $user->proofLink; 
} 
    public function build() 
{ 
    $location = storage_path("app/$this->URL"); 
    return $this->view('emails.confirmaccount')->attach($location); 
}