Open Download Dialog with PHP

2019-01-11 20:45发布

I am trying to make an online kickstart config file creator. After the file is created on the server how do I get the download dialog to pop up so the user can download it?

标签: php download
2条回答
三岁会撩人
2楼-- · 2019-01-11 21:23

the magic is in the content-disposition

send a file to client

查看更多
戒情不戒烟
3楼-- · 2019-01-11 21:37

Content-Disposition header..

// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');

http://au2.php.net/manual/en/function.header.php

查看更多
登录 后发表回答