<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Calculates the md5 hash of a given file</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ltrim.html">ltrim</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.md5.html">md5</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.md5-file" class="refentry"> <div class="refnamediv"> <h1 class="refname">md5_file</h1> <p class="verinfo">(PHP 4 >= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">md5_file</span> — <span class="dc-title">Calculates the md5 hash of a given file</span></p> </div> <div class="refsect1 description" id="refsect1-function.md5-file-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>md5_file</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$raw_output</code><span class="initializer"> = false</span></span> ] )</div> <p class="para rdfs-comment"> Calculates the MD5 hash of the file specified by the <em><code class="parameter">filename</code></em> parameter using the <a href="http://www.faqs.org/rfcs/rfc1321" class="link external">» RSA Data Security, Inc. MD5 Message-Digest Algorithm</a>, and returns that hash. The hash is a 32-character hexadecimal number. </p> </div> <div class="refsect1 parameters" id="refsect1-function.md5-file-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">filename</code></em></span> <dd> <p class="para"> The filename </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">raw_output</code></em></span> <dd> <p class="para"> When <strong><code>TRUE</code></strong>, returns the digest in raw binary format with a length of 16. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.md5-file-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a string on success, <strong><code>FALSE</code></strong> otherwise. </p> </div> <div class="refsect1 changelog" id="refsect1-function.md5-file-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.1.0</td> <td> Changed the function to use the streams API. It means that you can use it with wrappers, like <em>md5_file('http://example.com/..')</em> </td> </tr> <tr> <td>5.0.0</td> <td> Added the <em><code class="parameter">raw_output</code></em> parameter </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.md5-file-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4845"> <p><strong>Example #1 Usage example of <span class="function"><strong>md5_file()</strong></span></strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$file </span><span style="color: #007700">= </span><span style="color: #DD0000">'php-5.3.0alpha2-Win32-VC9-x64.zip'</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #DD0000">'MD5 file hash of ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$file </span><span style="color: #007700">. </span><span style="color: #DD0000">': ' </span><span style="color: #007700">. </span><span style="color: #0000BB">md5_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.md5-file-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.md5.html" class="function" rel="rdfs-seeAlso">md5()</a> - Calculate the md5 hash of a string</span></li> <li class="member"> <span class="function"><a href="function.sha1-file.html" class="function" rel="rdfs-seeAlso">sha1_file()</a> - Calculate the sha1 hash of a file</span></li> <li class="member"> <span class="function"><a href="function.crc32.html" class="function" rel="rdfs-seeAlso">crc32()</a> - Calculates the crc32 polynomial of a string</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ltrim.html">ltrim</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.md5.html">md5</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>