We investigate the generation of large scale magnetic fields in the universe from quantum fluctuations that are produced in the inflationary stage. By coupling these quantum fluctuations to the dilaton field and Ricci scalar, we show that the magnetic fields with the strength observed today can be produced. We consider two situations. First, the evolution of dilaton ends by starting the reheating stage. Second, the dilaton continues its evolution after reheating and then decays. We here consider the first case. In both cases, we come back to the usual Maxwell equations after inflation and then calculate present magnetic fields.