PHP reads csv to implement csv file download function_PHP tutorial

WBOY
Release: 2016-07-13 17:18:06
Original
741 people have browsed it

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('...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!