0👍
just change the fileName format when you trying to save it in your backend and excatly in the loop :
$upload_path = public_path('upload'); // there is no need to define variable in each loop itteration
foreach ($request->file("files") as $file) {
$file_name = $file->getClientOriginalName();
$generated_new_name = time() . '-'. $file_name .'.'. $file->getClientOriginalExtension();
$file->move($upload_path, $generated_new_name);
}
the problem is that the backend overrides the file because it has the same name because of the time() function so all the files will be created at the same time and all files coming from your frontend will have the same name and for sure only the last file will be saved, so you will think that the frontend just send one file but if you trying to do sizeOf($request->file("files")) it will give you the number of files that has been sent….
hopefully, this will solve your problem…
Source:stackexchange.com