Php 为什么Laravel 5邮件,我附加了一个.tmp文件?

Php 为什么Laravel 5邮件,我附加了一个.tmp文件?,php,laravel-5,mailer,Php,Laravel 5,Mailer,我试图在从表单发送的电子邮件中附加一个文件,问题是该文件正在向我发送.tmp 我的控制器 public function choiceAnalyst(Request $request){ $userSelect = $request->input('user'); $data = User::where('id', '=', $userSelect)->first(); $data->attach = $request->file('docume

我试图在从表单发送的电子邮件中附加一个文件,问题是该文件正在向我发送
.tmp

我的控制器

public function choiceAnalyst(Request $request){

    $userSelect = $request->input('user');
    $data = User::where('id', '=', $userSelect)->first();
    $data->attach = $request->file('document')->getRealPath();

    Mail::to('eaquino@spi.com.ve')->send(new AnalystMonth($data));

    return redirect()->route('home', ['message' => 'Correo enviado correctamente']);
}
我的班级

class AnalystMonth extends Mailable
{
    use Queueable, SerializesModels;

    public $user;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(User $user)
    {
        $this->user = $user;

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('mails.analystMonth')->attach($this->user->attach);
    }
}

我想我是通过提取文件时包含的
getRealPath()
方法获得了
.tmp
,但我不确定。如何使文件到达.tmp扩展名?

您将收到一个
.tmp
文件,因为该文件在您将其附加到邮件之前从未上载到服务器

$data->attach = storage_path('app/public/' . $request->file('document')->store('folder', 'public'));
您可以通过
存储
外观获得相同的结果:

$data->attach = Storage::disk('public')->path($request->file('document')->store('folder', 'public'));

非常感谢你,兄弟,我从昨天开始就在努力解决这个问题,非常感谢much@EdwinAquino没问题,祝你今天愉快!