2017-04-20 110 views
0

我嘗試從視圖中附加PDF文件希望在PDF中工作。但是當我嘗試將其作爲PDF文件到電子郵件,我得到FileByteStream.php線將PDF文件附加到郵件中

Swift_IoException 144:無法打開文件 閱讀[HTTP/1.0 200 OK的Cache-Control:NO-緩存,私人 內容處置:附件;文件名=「invoice.pdf」內容類型: 應用程序/ pdf

有人知道我在哪裏做錯了嗎?感謝很多提前

這裏我的控制器:

公共職能構建(){

$federation = Structure::where('id' , '1')->first(); 
    $structure = Structure::where(['id' => $this->order->structure_id])->first(); 
    $order = $this->order; 

    $url = url('/cotisationstructure/'.$this->order->id); 

    $pdf = app('dompdf.wrapper'); 
    $pdf->loadView('cotisation_structure.facturePDFsingle', compact('order' , 'structure' , 'federation')); 

    return $this->markdown('email.commande' ,compact('federation' , 'structure' , 'url')) 
     ->subject('Nouvelle Achat de Licences sur FFRXIII Licences & Compétitions') 
     ->attach($pdf->download('invoice.pdf')); 
} 
+0

你使用barryvdh/laravel-dompdf? –

+0

是的,我使用dompdf –

回答

1

你需要給文件名作爲附加功能string。欲瞭解更多檢查:https://laravel.com/docs/5.4/mail#attachments

+0

現在正在處理: - > attachData($ pdf-> output(),''。$ this-> order-> num_facture。'。pdf'); –

+1

您還應該指定第三個參數中的MIME類型: - > attachData($ pdf-> output(),''。$ this-> order-> num_facture。'。pdf',['mime'=>'application/pdf']) –

+0

是的非常感謝! –