Home > Net >  csv files downloading as txt when using download attribute of <a> tag in PHP
csv files downloading as txt when using download attribute of <a> tag in PHP

Time:06-21

I am trying to download File with csv extension using download attribute but it's downloading file with .txt extension.

Here's my code

<a href="log_files/log_files/abc.csv" download><button type="button" >Download</button></a>

Help me if you know the solution

CodePudding user response:

I had the same problem, just add the filename with .csv extension in the download attribute, like below

<a href="log_files/log_files/abc.csv" download="abc.csv"><button type="button" >Download</button></a>
  • Related