2017-12-27 380 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); 
}