Home > Backend Development > PHP Tutorial > PHP download file, a simple way to add response headers

PHP download file, a simple way to add response headers

墨辰丷
Release: 2023-03-28 21:50:02
Original
2387 people have browsed it

This article mainly introduces the simple method of downloading PHP files and adding response headers. Interested friends can refer to it. I hope it will be helpful to everyone.

is as follows:

//下载,添加响应头信息
header('Content-type:application/octet-stream');
header('Content-Disposition:attachment;filename="'.basename($file).'"');
header('Content-Length:'.filesize($file));
readfile($file);
Copy after login

Summary: The above is all of this article Content, I hope it will be helpful to everyone's study.

Related recommendations:

Use php to realize automatic login storage mechanism within a week

PHP Implement the thief program example

Use php to interact with the server and web front-end interface

##

The above is the detailed content of PHP download file, a simple way to add response headers. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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