PHP header function directly prompts the saved code when downloading the file

WBOY
Release: 2016-07-25 09:00:36
Original
792 people have browsed it
  1. $filename = 'path + actual file name';
  2. //Type of file
  3. header('Content-type: application/pdf');
  4. //Name displayed when downloading
  5. header ('Content-Disposition: attachment; filename="Save file name.pdf"');
  6. readfile("$filename");
  7. exit();
  8. ?>
Copy code

Provide an online withdrawal There are many ways to implement downloading using php header functions.

  1. if (isset($link))
  2. {
  3. Header("HTTP/1.1 303 See Other");
  4. Header("Location: $link");
  5. exit;
  6. }
  7. ?>
Copy the code

$link is the actual path of the file.

Attached is a list of Content-Type types of HTTP headers that the server responds to.



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!