<!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>Error Messages Explained</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="features.file-upload.post-method.html">POST method uploads</a></div> <div class="next" style="text-align: right; float: right;"><a href="features.file-upload.common-pitfalls.html">Common Pitfalls</a></div> <div class="up"><a href="features.file-upload.html">Handling file uploads</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="features.file-upload.errors" class="sect1"> <h2 class="title">Error Messages Explained</h2> <p class="simpara"> Since PHP 4.2.0, PHP returns an appropriate error code along with the file array. The error code can be found in the <em>error</em> segment of the file array that is created during the file upload by PHP. In other words, the error might be found in <var class="varname"><var class="varname"><a href="reserved.variables.files.html" class="classname">$_FILES['userfile']['error']</a></var></var>. </p> <p class="para"> <dl> <dt> <span class="term"><strong><code>UPLOAD_ERR_OK</code></strong></span> <dd> <p class="para"> Value: 0; There is no error, the file uploaded with success. </p> </dd> </dt> <dt> <span class="term"><strong><code>UPLOAD_ERR_INI_SIZE</code></strong></span> <dd> <p class="para"> Value: 1; The uploaded file exceeds the <a href="ini.core.html#ini.upload-max-filesize" class="link">upload_max_filesize</a> directive in <var class="filename">php.ini</var>. </p> </dd> </dt> <dt> <span class="term"><strong><code>UPLOAD_ERR_FORM_SIZE</code></strong></span> <dd> <p class="para"> Value: 2; The uploaded file exceeds the <em class="emphasis">MAX_FILE_SIZE</em> directive that was specified in the HTML form. </p> </dd> </dt> <dt> <span class="term"><strong><code>UPLOAD_ERR_PARTIAL</code></strong></span> <dd> <p class="para"> Value: 3; The uploaded file was only partially uploaded. </p> </dd> </dt> <dt> <span class="term"><strong><code>UPLOAD_ERR_NO_FILE</code></strong></span> <dd> <p class="para"> Value: 4; No file was uploaded. </p> </dd> </dt> <dt> <span class="term"><strong><code>UPLOAD_ERR_NO_TMP_DIR</code></strong></span> <dd> <p class="para"> Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3. </p> </dd> </dt> <dt> <span class="term"><strong><code>UPLOAD_ERR_CANT_WRITE</code></strong></span> <dd> <p class="para"> Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0. </p> </dd> </dt> <dt> <span class="term"><strong><code>UPLOAD_ERR_EXTENSION</code></strong></span> <dd> <p class="para"> Value: 8; A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> may help. Introduced in PHP 5.2.0. </p> </dd> </dt> </dl> </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> These became PHP constants in PHP 4.3.0. </p> </p></blockquote> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="features.file-upload.post-method.html">POST method uploads</a></div> <div class="next" style="text-align: right; float: right;"><a href="features.file-upload.common-pitfalls.html">Common Pitfalls</a></div> <div class="up"><a href="features.file-upload.html">Handling file uploads</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>