Content-Disposition
- ref:http://phpspot.org/blog/archives/2008/02/phpdlphp.html
- ref:http://b.hatena.ne.jp/entry/http://phpspot.org/blog/archives/2008/02/phpdlphp.html
phpspot もどうかと思うが、これでブックマークが 280 とかついているのをみると、
これだから PHP ユーザは
と言いたくもなるというものであります。いや、ツッコミこみのコメントをしている人もいるけど。
とりあえず、
- Content-Disposition ヘッダに disposition-type がない。これだと Content-type: charset=utf-8 みたいなもんですよ。
- filename の部分は引用符で囲め
- ZIP なのに Content-type が application/octet-stream って。
ようするに
<?php header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="dl.zip"'); ?>
とかそんな感じね。
あと
<?php echo file_get_contents('dl.zip'); ?>
って、一度ファイルの中身をメモリに載せるつもりですか。せめて、readfile を使うべきでは。
細かいことをいうと、output buffering の care もしてやらないといけないとか、Partial Request とかどうするの、とか。
まぁ、HTTP_Download という PEAR パッケージがあるらしいのでそれ使っとけという話もあるね。