Im trying to upload multiple images to via below code in laravel. In my form there are 3 types of images to be selected to upload. When user select all the images and then submit the form. I need to upload all the images to same folder . First images get uploaded in to the folder. But then it gives me below error.
The file "1575738164-main-slider2.webp" was not uploaded due to an unknown error.
Controller
if ($request->hasFile('image') && $request->hasFile('image_575') && $request->hasFile('image_768')){
$file = $request->image;
$file_575 = $request->image_575;
$file_768 = $request->image_768;
$name = time().'-'.$file->getClientOriginalName();
$name_575 = time().'-'.$file_575->getClientOriginalName();
$name_768 = time().'-'.$file_768->getClientOriginalName();
$names = [ $name , $name_575 , $name_768];
foreach ( $names as $n){
$file->move('uploads/banners/',$n);
}
$banner = new Banner();
$banner->name = $name;
$banner->name_575 = $name_575;
$banner->name_768 = $name_768;
$banner -> side_color = $request -> side_color ;
$banner->type = $request->type;
$banner->save();
}
Please note that I have almost gone through below questions. Laravel: The file was not uploaded due to an unknown error