What you found is very partial. You're missing the most important part of the code (the import_pre_11 and import_11 functions themselves)...
Are your users going to be using Adobe Acrobat (ie, not the free Reader) to fill in these files? If not, what you're asking for is not possible, unless a very special right is first applied to your file.
Yeah, I haven't done any extensive testing. Just providing a piece of script I'e found which was working for me upon very brief testing.
The users will be using Acrobat Reader
In that case it's a no-starter. The only way they can attach files (again, unless you apply this very special right to the file) is by using the Attach File commenting tool, and then you have no way of changing the file name of the attached files.
That code is from a demo file I provided: http://acroscript.net/pdf/demos/importFileJS_v1.pdf
It works with Reader 11 and later and prompts the user to select a file to be attached and doesn't require any usage rights. Although you are not able to change the file name, you can set the "name" and "contents" property of the file attachment. The name property doesn't show in the attachments panel, but the contents appears as the Description. You could use a script to display the attachments and include the name property though.