在我的laravel
-application 我有一个<form>
可以上传多个文件的地方。当我提交表单时,多个文件被存储到 中database
,但是应该存储文件路径的表列attachment
总是显示1
(真)。
if (request()->has('attachment_files')) {
$files = request()->attachment_files;
foreach ($files as $file) {
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$filesize = $file->getClientSize();
$path = Storage::disk('local')->put('attachments' . $filename, $extension);
$data = SingleApplicationFile::create([
'files_id' => $application->id,
'single_application_id' => $application->id,
'attachment' => $path,
'attachment_name' => $filename,
'attachment_size' => $filesize,
]);
$attachment_file[] = $data;
new SingleApplicationFile($attachment_file);
}
}
如前所述,该行$path = Storage::disk('local')->put('attachments' . $filename, $extension);
总是给我true
,并且在数据库列中存储了一个“1”。
我之前使用此方法进行单个文件上传,在这种情况下,提到的行存储attachments/somefilename.pdf
- 那么这里的问题是什么