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

PHP download file, a simple way to add response headers

墨辰丷
墨辰丷Original
2018-06-01 10:41:522324browse

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);

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!

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