Answers for "javascript download file from url on click"

0

how to download file html button

<a href="file.doc">Download!</a>
Posted by: Guest on December-24-2020
0

javascript download file from url

const fs = require('fs');
const https = require('https');
  
// URL of the image
const url = 'GFG.jpeg';
  
https.get(url,(res) => {
    // Image will be stored at this path
    const path = `${__dirname}/files/img.jpeg`; 
    const filePath = fs.createWriteStream(path);
    res.pipe(filePath);
    filePath.on('finish',() => {
        filePath.close();
        console.log('Download Completed'); 
    })
})
Posted by: Guest on July-06-2021
-1

javascript download file on click

You can trigger a download with the HTML5 download attribute.

<a href="path_to_file" download="proposed_file_name">Download</a>
Posted by: Guest on October-07-2020

Code answers related to "javascript download file from url on click"

Browse Popular Code Answers by Language