我正在构建一个基于 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- 行上收到错误“Call to a member function store() on null” >商店('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');
关于php - 上传 PDF 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58100219/