简体   繁体   中英

How to download a file on a remote machine on button click in html?

I'm trying to download a file on a remote machine on button click in html. Like I have link of a file which is " File link: - https://perso.telecom-paristech.fr/eagan/class/igr204/data/Camera.csv ". I want to download this file to a remote machine on a button click in html. I don't know how to connect to remote machine for downloading that file. So it will be like, when I'm clicking on download button in html file on my machine / local machine , this file should get downloaded to the remote machine or some other machine instead of my local machine. Will "ip address" will be sufficient to connect to remote machine and store the file in that machine?

Can someone please help to do that or tell me other way to get it done?

Web browsers provide no mechanism for a website to determine where a file will be saved, so even if they had access to the target machine, you couldn't do this with client-side code.

You need to write a web service (you can use whatever programming language you like, my preference these days would be to use JavaScript with the Express module (to provide the web service) and Axios (to do the download) for Node.js).

You need to make an HTTP request to the web service when the button is clicked (this can be as simple as using a <form> with the action URL pointing to the web service so a request is made to it when the submit button is clicked.

Then the web server needs to perform the download.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM