Level 102
What error are you getting?
How do you store file in database? I'm trying to store my file in database but I got error message with fail upload.
My path folder application also are not created.
One of the method that I have tried
public function store(Request $request)
{
$this->validate($request,[
'proposal'=>'required|mimes:doc,docx,pdf |max:2048'
]);
//handle the file upload
if($request->hasFile('proposal')){ // to check if user has opted to upload the file
// get filename with extention
$filenameWithExt = $request->file('proposal')->getClientOriginalName();
//get just filename
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
//get ext (extention)
$extension =$request->file('proposal')->getClientOriginalExtension();
//filename to store
$fileNameToStore = $filename .'_'.time().'.'.$extension;
$path = $request->file('proposal')->storeAs('public/application',$fileNameToStore);
}
$application = new Application;
$application->proposal =$fileNameToStore;
$application->user_id = auth()->user()->id;
$application->save();
return redirect('/user/application/view')->with('success', 'Application submitted');
}
Please or to participate in this conversation.