Updated the ['error'] constants, which are available as of PHP 4.3.0

['error'] itself became available in PHP 4.2.0


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@88514 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2002-07-12 22:15:29 +00:00
parent 851e4dc7a2
commit ad6c85a000

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.44 $ -->
<!-- $Revision: 1.45 $ -->
<chapter id="features.file-upload">
<title>Handling file uploads</title>
@ -225,60 +225,64 @@ move_uploaded_file($_FILES['userfile']['tmp_name'], "/place/to/put/uploaded/file
<sect1 id="features.file-upload.errors">
<title>Error Messages Explained</title>
<simpara>
There is a lot that can go wrong during a file upload. PHP returns apropriate
error messages beside the usual warnings. The error message can be found in the
["error"] segment of the array that is created during the file upload.
This is either $userfile["error"] if <link linkend="ini.register-globals">
register_globals</link> is turned on in &php.ini;, or
$HTTP_POST_FILES["userfile"]["error"] for PHP versions before 4.1.0, or at last
and mostly recommended $_FILES["userfile"]["error"].
Since PHP 4.2.0, PHP returns an appropriate error code along with the
file array. The error code can be found in the
<emphasis>["error"]</emphasis> segment of the file array that is created
during the file upload by PHP. In otherwords, the error might be
found in <varname>$_FILES['userfile']['error']</varname>. An example:
</simpara>
<para>
<variablelist>
<varlistentry>
<term><varname>UPLOAD_ERROR_A</varname></term>
<term><varname>UPLOAD_ERROR_OK</varname></term>
<listitem>
<para>
Value: 1; the uploaded file exceeds the upload_max_filesize directive
that is specified in &php.ini;.
Value: 0; There is no error, the file uploaded with success.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UPLOAD_ERROR_B</varname></term>
<term><varname>UPLOAD_ERROR_INI_SIZE</varname></term>
<listitem>
<para>
Value: 2; the uploaded file exceeds the MAX_FILE_SIZE directive
that was specified in the html form.
Value: 1; The uploaded file exceeds the
<link ini="ini.upload-max-filesize">upload_max_filesize</link>
directive in &php.ini;.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UPLOAD_ERROR_C</varname></term>
<term><varname>UPLOAD_ERROR_FORM_SIZE</varname></term>
<listitem>
<para>
Value: 3; the uploaded file was only partially uploaded.
Value: 2; The uploaded file exceeds the <emphasis>MAX_FILE_SIZE</emphasis>
directive that was specified in the html form.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UPLOAD_ERROR_D</varname></term>
<term><varname>UPLOAD_ERROR_PARTIAL</varname></term>
<listitem>
<para>
Value: 4; no file was uploaded.
Value: 3; The uploaded file was only partially uploaded.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UPLOAD_ERROR_E</varname></term>
<term><varname>UPLOAD_ERROR_NO_FILE</varname></term>
<listitem>
<para>
Value: 5; the uploaded file has a size of 0 (read: zero) bytes.
Value: 4; No file was uploaded.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</para>
<para>
<note>
These became PHP constants in PHP 4.3.0
</note>
</para>
</sect1>
<sect1 id="features.file-upload.common-pitfalls">