0

I have tried <a download="file_path" href="filepath"> and

var elem = document.createElement('a');
elem.href = url;
elem.crossOrigin = "Anonymous";
elem.target = '_blank';
elem.download = file_name;
elem.click();
elem.remove()

Buts gets CORS error while using jpg as file path, Pdf works the same. The source file is from subdomain. Please help me.

var elem = document.createElement('a');
elem.href = url;
elem.crossOrigin = "Anonymous";
elem.target = '_blank';
elem.download = file_name;
elem.click();
elem.remove()
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Deepz
  • 1
  • 2
  • 1
    What you're attempting to do is not possible. When using the `download `attribute the content has to be on the same domain as the calling page. – Rory McCrossan Feb 03 '23 at 12:09

0 Answers0