Download CSV file in WEB directory

Asked

Viewed 16 times

0

I am trying to download a CSV file in the directory but it is downloaded in . TXT

Unsuccessful attempts (PHP 7.1)

header('Content-type: text/csv; charset=UTF-8')
header("Content-Type: application/csv");
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');

Code

<a download href="<?php echo$csv; ?>" class="btn btn-success"><i class="fa fa-arrow-circle-down" aria-hidden="true"></i> BAIXAR CSV</a>

$csv ='assets/tabelas-csv/planilha-produtos-'.$date.'.csv';

1 answer

1


makes it simpler. If you already have the file and know where it ta only adds the download tag in the link.

ex:

<a href="pasta/diretorio/nomedoarquivo.csv" download="nomedoarquivo.csv" target="_blank">Click here to download</a>

resolves ?

  • 1

    I tried everything but that and it worked, thank you !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.