Php 存储文件夹中的Laravel 5.2电子邮件附件pdf文件

Php 存储文件夹中的Laravel 5.2电子邮件附件pdf文件,php,email,laravel-5,attachment,Php,Email,Laravel 5,Attachment,我在存储/invoice/filename.pdf中有一个文件 $data=[ 'billing_filepath'=>storage_path('/invoice/filename.pdf');, 'invoice.pdf']; 我使用了laravel邮件功能, 电子邮件发送成功,但附件已崩溃。我怎样才能修好它 $message->attachData($data['billing_filepath'], data['billing_file_name']); 由于PDF文

我在
存储/invoice/filename.pdf中有一个文件

$data=[
 'billing_filepath'=>storage_path('/invoice/filename.pdf');,
 'invoice.pdf'];
我使用了laravel邮件功能, 电子邮件发送成功,但附件已崩溃。我怎样才能修好它

$message->attachData($data['billing_filepath'], data['billing_file_name']);

由于PDF文件保存在磁盘上,请使用
attach()
而不是
attachData()


attachData()
用于发送原始数据,这些数据通常是程序生成的,您不想保存在磁盘上
attachData()
接受第一个参数的原始数据字节而不是文件路径。

我收到一条错误消息,FileByteStream.php行144中的Swift\u IoException:无法打开文件进行读取[/var/www/vhosts/uneek\u dev/uneek.sf.com.au/httpdocs/web/storage/invoice/order\u invoice.pdf]检查存储和发票目录的权限(如果尚未更改,请将其更改为755)。尝试使用
realpath()
而不是
storage\u path()
,检查此处:
$message->attach($data['billing_filepath'],[
  'as' => data['billing_file_name'],
  'mime' => 'application/pdf'
]);