Spray Foam/ Foam Board Hybrid?
What you're thinking about probably won't work as well as sprayed in Icynene (or similar) foam, but it won't hurt either. If you opt to use the foam board, you can seal up the gaps with spray foam. Great stuff is an option, but I'd suggest making a small investment in a spray foam "pistol" type gun that will spray in any position. The guns just take cartridges of foam, and work awesome.
If you opt for foam board, please please please plan on covering it with something like thin plywood or sheetrock. It is incredibly combustable, and is required by code and product listing (and common sense) to have an ignition barrier applied over it. If it is sealed off without much available air, it won't burn nearly as effectively, and there's no chance an outside source will ignite it. Ever see the video of the Rhode Island nightclub fire a couple years back? Yup, foamboard. I hate the stuff.