How can I use a function from .js file in the oneditprepare function?

Remember that the html file runs in the front-end (browser) and the js in the back-end (server), Just because you loaded your ftp client in your js file does not mean it is available at the front end.

To link the 2 together, it is common to use an API - check out the core serial node for an example.