I need to validate multiple uploaded files, making sure they are of a specific type and under 2048kb. The below doesn't appear to check all files in the array
'files' and just presumes the posted files of invalid mime type as it seems to be checking the array object and not its contents.
public function fileUpload(Request $request)
{
$validator = Validator::make($request->all(), [
'files' => 'required|mimes:jpeg,jpg,png',
]);
if ($validator->fails())
{
return response()->json(array(
'success' => false,
'errors' => $validator->getMessageBag()->toArray()
), 400); }
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…