I think I see the problem:
The Download button in your form is just a standard button, it does not actually perform any action, the form is not being submited when the download button is clicked.
change the download button:
<input type="button" id="download" name="download" value="Download" />
to be a subit button:
<input type="submit" id="download" name="download" value="Download" />