问题
I'm currently working on a browser based project where I'm using JavaScript, HTML and CSS for the first time, having had no past experience with these languages. Basically the project involves the following: (1) allowing the user to upload a .csv file via the following code:
<input id="files" type="file" accept=".csv" />
(2) Reading the file, (3) converting to a YAML file (.yml) and (4) uploading it to a remote server via SSH/SCP/SFTP.
I've done (1) and (2) but what I'm having real trouble with is part 4. My questions are:
- is it possible in JavaScript to upload a file to a remote server via SSH/SCP/SFTP, keeping in mind that this is a browser based project.
- if no, what are some alternative browser based methods of allowing a user to do this?
- any good resources on making .yml files using JavaScript?
Thank you.
回答1:
Security in client-side JavaScript is a flawed idea and due to this it's unlikely that you will find JS-based SSH implementation (SSH is quite complex protocol family). The best options are either to have a Java applet to do the job (the applet must be properly digitally signed to be allowed to connect to third-party location) or upload the file to the web server and have it upload the file elsewhere.
来源:https://stackoverflow.com/questions/23030066/javascript-file-transfer-ssh