1

I want to hit a URL to download a file and rename the file I get as response using javascript. I tried the following code but its not working. The file is getting downloaded but renaming is not happening

function downloadAndRename(url, fileName){
    var anchor = document.createElement('a');
    $('body').append(anchor);
    anchor.href = url;
    anchor.download = fileName;
    anchor.click();
}

Is there any other way by which I can do this?

Hari Narayanan
  • 184
  • 1
  • 9

0 Answers0