Using the persons first-name as the email from-address might be causing a problem with your mail server - it might require that the email is sent from a valid, configured email address for all sorts of reasons - has it ever sent the email correctly?
The form upload part appears after you’ve executed the javascript window.location() call, which I assume (I don’t really know js) redirects the page before it hits the code in your first screen-shot, guessing that the first screen-shot (from the line numbers) appears after the second one.