Aha! Here it go, in your code:
var file_input = document.createElement('input');
file_input.type = 'file';
file_input.id = 'file_upload_input';
This is missing:
file_input.attr('name', 'myfile');
This is the only part that your HTML form has, and dynamical doesn't, so I guess that's the trick
If an HTML doesn't have a name it won't be passed to the querystring or the POST data - there will be no way to retrieve it from PHP This is from here - stackoverflow