Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Laravel中上载带有联系人表单的文件并发送电子邮件_Php_Laravel_Email - Fatal编程技术网

Php 在Laravel中上载带有联系人表单的文件并发送电子邮件

Php 在Laravel中上载带有联系人表单的文件并发送电子邮件,php,laravel,email,Php,Laravel,Email,我试图上传联合国文件并将其附加到我发送的电子邮件中,但它不起作用 在my MailFile.php中(使用php artisan make:mail创建) 但它不起作用。我觉得我用的方法不对。你能帮我吗?你能说得更清楚些吗?哪部分不起作用?您收到了什么错误?尝试从请求加载文件,如$request->file('name-pdf')而不是$request->input您能更明确一些吗?哪部分不起作用?您收到了什么错误?请尝试从请求加载文件,如$request->file('name-pdf')而不

我试图上传联合国文件并将其附加到我发送的电子邮件中,但它不起作用

在my MailFile.php中(使用php artisan make:mail创建)


但它不起作用。我觉得我用的方法不对。你能帮我吗?

你能说得更清楚些吗?哪部分不起作用?您收到了什么错误?尝试从请求加载文件,如
$request->file('name-pdf')
而不是
$request->input
您能更明确一些吗?哪部分不起作用?您收到了什么错误?请尝试从请求加载文件,如
$request->file('name-pdf')
而不是
$request->input
public function __construct(Request $request)
{
    $this->namePdf        = $request->input('name-pdf');
    $this->subjectPdf     = $request->input('subject-pdf');
    $this->emailPdf       = $request->input('email-pdf');
    $this->filePdf        = $request->input('file-pdf');
}


public function build()
{
    return $this->view('mails.sendFile')
                ->subject($this->subjectPdf)
                ->from('test@test.be', 'John Doe')
                ->attach($this->filePdf->getRealPath(), [
                    'as' => 'file.' . $this->filePdf->getClientOriginalExtension(),
                    'mime' => $this->filePdf->getMimeType()
                ]);
}