http_send_file
(PECL pecl_http >= 0.1.0)
http_send_file — ファイルを送信する
説明
bool http_send_file
( string $file
)
(複数の) range リクエストをサポートするファイルを送信します。
この関数の振る舞いおよびその後の動作は、以下の INI 設定 http.send.not_found_404 そして http.log.not_found に依存します。
INI 設定 http.send.not_found_404 が有効で INI 設定 http.log.not_found が書き込み可能なファイルを指している場合は、file が見つからないときにそこにログメッセージが書き込まれます。
パラメータ
- file
-
送信するファイル。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。
例
例1 http_send_file() の例
<?php
http_send_content_disposition("document.pdf", true);
http_send_content_type("application/pdf");
http_throttle(0.1, 2048);
http_send_file("../report.pdf");
?>
上の例の出力は以下となります。
HTTP/1.1 206 Partial Content X-Powered-By: PHP/5.2.2 Accept-Ranges: bytes Content-Length: 12345 Content-Range: bytes 0-12344 Content-Type: application/pdf Content-Disposition: inline; filename="document.pdf" %PDF...
参考
- http_send_data() - 任意のデータを送信する
- http_send_stream() - ストリームを送信する
- http_throttle() - HTTP 抑止処理
- http_send_content_type() - Content-Type を送信する
- http_send_content_disposition() - Content-Disposition を送信する
- PHP 5.1.0 以降を使用している場合は HttpResponse クラス
http_send_file
There are no user contributed notes for this page.