上传 PDF 问题

Upload PDF Issue

我正在构建一个基于 HelloSign API 的应用程序,为此我们需要将 PDF 上传到 HelloSign 以用作模板,但是我遇到的问题是我还需要存储一份我们这边的 PDF,我已经编写了代码,但它不起作用。我在 null

上收到对成员函数 store() 的错误调用

我已经用谷歌搜索了这个以及如何写这个,问题是我们已经用 pdf 设置了模板,但也想存储文件

public function store(Request $request)
    {
        $this->template->setClientId(config('hellosign.client_id'));
        $this->template->addFile($request->file('pdf'));

        // here we upload the raw pdf to the database

        $path = $request->file->store('pdf');
        // create the upload and store the url
        $fileData = new Upload;
        $fileData->user_id = 1;
        $fileData->name = $request->file->getClientOriginalName();
        $fileData->path = $path;
        $fileData->timestamps = now();
        $fileData->save();
        /**/

预期的结果是上传的时候把文件上传到服务器,实际的结果是在$path = $request->file->store('pdf');

这里是 $request->file('pdf')

的转储
#convertedFiles: array:1 [▼
    "pdf" => UploadedFile {#468 ▼
      -test: false
      -originalName: "User Setup From.pdf"
      -mimeType: "application/pdf"
      -error: 0
      #hashName: null
      path: "/tmp"
      filename: "phpmTqOhb"
      basename: "phpmTqOhb"
      pathname: "/tmp/phpmTqOhb"
      extension: ""
      realPath: "/tmp/phpmTqOhb"
      aTime: 2019-09-25 14:34:22
      mTime: 2019-09-25 14:34:22
      cTime: 2019-09-25 14:34:22
      inode: 398565
      size: 567747
      perms: 0100600
      owner: 1000
      group: 1000
      type: "file"
      writable: true
      readable: true
      executable: false
      file: true
      dir: false
      link: false
    }
  ]

字段名称好像是pdf

你想要

$path = $request->pdf->store('pdf');