Home  >  Article  >  Backend Development  >  PHP reads csv to implement csv file download function_PHP tutorial

PHP reads csv to implement csv file download function_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:18:06742browse

The first paragraph is to read the file and download it.
The second paragraph is string download.

Copy code The code is as follows:

$fileName = "prefs.csv";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileName);
header('Content-Transfer-Encoding: binary' );
header('Content-Length: ' . filesize($fileName));
readfile($fileName);

Copy code The code is as follows:

$fileName = "pref_" . date("YmdHis ") . ".csv";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileName);
echo $csv;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621682.htmlTechArticleThe first paragraph is to read the file and download it. The second paragraph is string download. Copy the code The code is as follows: ?php $fileName = "prefs.csv"; header('Content-Type: application/octet-stream'); header('...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn