The contribution of high-redshift galaxies to the near-infrared background