Mar 19, 2021
0
Level 1
Upload Files in storage
There is a table house. It has four columns (where the path to the downloaded file should be saved). I tried to download one file in the controller for the test, but it did not appear in the database
$this->validate($request, [
'passport' => 'required'
]);
$homes = Houses::query()->create([
'passport' => $request->get('passport')
]
);
$request->validate([
'file' => 'required|mimes:docs,txt,doc,xls,pdf,docx, docm,rtf,xps,xml|max:4098'
]);
$fileModel = new File;
if ($request->file()) {
$fileName = time() . '_' . $request->file - getClientOriginalName();
$filePath = $request->file('passport')->storeAs('passport_house', $fileName, 'public');
$fileModel->name = time() . '_' . $request->file->getClientOriginalName();
$fileModel->file_path = '/storage/' . $filePath;
$fileModel->save();
}
return redirect()->route('homes.index');
}
How do I fix this?
Please or to participate in this conversation.