我想在应用程序表单上的用户输入文件中附加电子邮件文件,但我不知道热得好。我尝试了这段代码,但附加文件是在下载附件后打开时无效的文件(图片,pdf等..)。这是我的代码
public function __construct(Request $request, Position $position)
{
$this->request = $request;
$this->position = $position;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$email = $this->from('xxxx@xxxxx.com', $this->request->first_name . ' ' . $this->request->last_name)
->replyTo($this->request->email, $this->request->first_name . ' ' . $this->request->last_name)
->subject('Application for ' . $this->position->name)
->view('emails.application');
$counter = 1;
foreach($this->request->resume as $resume) {
if ($resume->isValid()) {
$path = $resume->path();
$extension = $resume->extension();
$email->attachData($path, 'file' . $counter. '.' . $extension);
}
$counter++;
}
return $email;
}