Change name of download in javascript

前端 未结 3 1138
失恋的感觉
失恋的感觉 2020-11-27 07:08

If a user clicks on a downloadable link such as

Download

Is there a client-side (html or javas

3条回答
  •  心在旅途
    2020-11-27 07:30

    You can use Filesaver.js script written by eligrey(Im using angularjs in the example here) You can achieve the same in classic javascript using XmlHttpRequest object

    //In your html code , add these : ->
    
     
    
    
    //In your Javascript:- 
    
    $http({
            url: "url where the file is located",
            method: "GET",
            responseType: "blob"
        }).then(function (response) {
    
    saveAs(response.data,"newfilename.extension");
    
    })
    

提交回复
热议问题