📄 function.http-send-file.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Send file</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.http-send-data.html">http_send_data</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.http-send-last-modified.html">http_send_last_modified</a></div> <div class="up"><a href="ref.http.html">HTTP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.http-send-file" class="refentry"> <div class="refnamediv"> <h1 class="refname">http_send_file</h1> <p class="verinfo">(PECL pecl_http:0.1.0-1.5.5)</p><p class="refpurpose"><span class="refname">http_send_file</span> — <span class="dc-title">Send file</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>http_send_file</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$file</tt></span> )</div> <p class="para rdfs-comment"> Sends a file with support for (multiple) range requests. </p> <p class="para"> This functions behaviour and further action is dependent on the following <a href="http.configuration.html" class="link">INI setting</a>s: <a href="http.configuration.html#http.configuration.send.not_found_404" class="link">http.send.not_found_404</a> and <a href="http.configuration.html#http.configuration.log.not_found" class="link">http.log.not_found</a>. </p> <p class="para"> If the <a href="http.configuration.html" class="link">INI setting</a> <a href="http.configuration.html#http.configuration.send.not_found_404" class="link">http.send.not_found_404</a> is enabled and the <a href="http.configuration.html" class="link">INI setting</a> <a href="http.configuration.html#http.configuration.log.not_found" class="link">http.log.not_found</a> points to a writable file, a log message is written when the <i><tt class="parameter">file</tt></i> was not found. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">file</tt></i></span> <dd> <p class="para"> the file to send </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>http_send_file()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />http_send_content_disposition</span><span style="color: #007700">(</span><span style="color: #DD0000">"document.pdf"</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_send_content_type</span><span style="color: #007700">(</span><span style="color: #DD0000">"application/pdf"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_throttle</span><span style="color: #007700">(</span><span style="color: #0000BB">0.1</span><span style="color: #007700">, </span><span style="color: #0000BB">2048</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_send_file</span><span style="color: #007700">(</span><span style="color: #DD0000">"../report.pdf"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>HTTP/1.1 206 Partial ContentX-Powered-By: PHP/5.2.2Accept-Ranges: bytesContent-Length: 12345Content-Range: bytes 0-12344Content-Type: application/pdfContent-Disposition: inline; filename="document.pdf"%PDF...</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.http-send-data.html" class="function" rel="rdfs-seeAlso">http_send_data()</a></li> <li class="member"><a href="function.http-send-stream.html" class="function" rel="rdfs-seeAlso">http_send_stream()</a></li> <li class="member"><a href="function.http-throttle.html" class="function" rel="rdfs-seeAlso">http_throttle()</a></li> <li class="member"><a href="function.http-send-content-type.html" class="function" rel="rdfs-seeAlso">http_send_content_type()</a></li> <li class="member"><a href="function.http-send-content-disposition.html" class="function" rel="rdfs-seeAlso">http_send_content_disposition()</a></li> <li class="member">the <a href="class.httpresponse.html" class="link"><b class="classname">HttpResponse</b></a> class if you are using PHP 5.1.0and above</li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.http-send-data.html">http_send_data</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.http-send-last-modified.html">http_send_last_modified</a></div> <div class="up"><a href="ref.http.html">HTTP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -