$files = $request->file('file');
foreach ($files as $file){
$filename = time().'.'.$file->getClientOriginalExtension();
$location = public_path('uploads/'.$filename);
$request->file->move(public_path('/uploads'), end($filename));
$filename_arr = [];
array_push($filename_arr, $filename);
$filename = json_encode($filename_arr);
$upload->filename = $filename;
}
I have checked several others codes online but they seem to be working fine but mine keeps saying that move cannot be used on an array
You're using $request->file array instead of $file element of the array. So, change this:
$request->file->move(public_path('/uploads'), end($filename));
To:
$file->move(public_path('/uploads'), end($filename));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With