Add a check if req.files array is not undefined before accessing it