dave Thu Dec 18 10:08:05 2003 EDT
Modified files: /phpdoc/en/features file-upload.xml Log: - Various typos, and some didou-inspired syntax formatting. Index: phpdoc/en/features/file-upload.xml diff -u phpdoc/en/features/file-upload.xml:1.65 phpdoc/en/features/file-upload.xml:1.66 --- phpdoc/en/features/file-upload.xml:1.65 Tue Sep 30 04:33:25 2003 +++ phpdoc/en/features/file-upload.xml Thu Dec 18 10:08:04 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.65 $ --> +<!-- $Revision: 1.66 $ --> <chapter id="features.file-upload"> <title>Handling file uploads</title> @@ -137,7 +137,7 @@ </para> <note> <para> - In PHP versions prior 4.1.0 this was named + In PHP versions prior to 4.1.0 this was named <varname>$HTTP_POST_FILES</varname> and it's not an <link linkend="language.variables.superglobals">autoglobal</link> variable like <varname>$_FILES</varname> is. PHP 3 does not @@ -176,12 +176,12 @@ <programlisting role="php"> <![CDATA[ <?php -// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of -// $_FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_file() -// instead of move_uploaded_file +// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead +// of $_FILES. In PHP versions earlier than 4.0.3, use copy() and +// is_uploaded_file() instead of move_uploaded_file. $uploaddir = '/var/www/uploads/'; -$uploadfile = $uploaddir. $_FILES['userfile']['name']; +$uploadfile = $uploaddir . $_FILES['userfile']['name']; print "<pre>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { @@ -202,7 +202,7 @@ <simpara> The PHP script which receives the uploaded file should implement whatever logic is necessary for determining what should be done - with the uploaded file. You can for example use the + with the uploaded file. You can, for example, use the <varname>$_FILES['userfile']['size']</varname> variable to throw away any files that are either too small or too big. You could use the @@ -231,7 +231,7 @@ 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 + during the file upload by PHP. In other words, the error might be found in <varname>$_FILES['userfile']['error']</varname>. </simpara> <para> @@ -259,7 +259,7 @@ <listitem> <para> Value: 2; The uploaded file exceeds the <emphasis>MAX_FILE_SIZE</emphasis> - directive that was specified in the html form. + directive that was specified in the HTML form. </para> </listitem> </varlistentry> @@ -283,7 +283,7 @@ </para> <note> <para> - These became PHP constants in PHP 4.3.0 + These became PHP constants in PHP 4.3.0. </para> </note> </sect1> @@ -297,15 +297,15 @@ The default is 2 Megabytes. </simpara> <simpara> - If memory limit is enabled, larger <link + If a memory limit is enabled, a larger <link linkend="ini.memory-limit">memory_limit</link> may be needed. Make - sure to set <link linkend="ini.memory-limit">memory_limit</link> + sure you set <link linkend="ini.memory-limit">memory_limit</link> large enough. </simpara> <simpara> If <link linkend="ini.max-execution-time">max_execution_time</link> - is set too small, script execution may be exceeded the value. Make - sure to set <literal>max_execution_time</literal> large enough. + is set too small, script execution may be exceeded by the value. Make + sure you set <literal>max_execution_time</literal> large enough. </simpara> <note> <simpara> @@ -319,8 +319,8 @@ </simpara> </note> <simpara> - If <link linkend="ini.post-max-size">post_max_size</link> set too - small, large files cannot be uploaded. Make sure to set + If <link linkend="ini.post-max-size">post_max_size</link> is set too + small, large files cannot be uploaded. Make sure you set <literal>post_max_size</literal> large enough. </simpara> <simpara> @@ -353,7 +353,7 @@ </simpara> <note> <para> - Support for multiple file uploads was added in version 3.0.10. + Support for multiple file uploads was added in PHP 3.0.10. </para> </note> <para> @@ -376,8 +376,8 @@ <varname>$_FILES['userfile']</varname>, <varname>$_FILES['userfile']['name']</varname>, and <varname>$_FILES['userfile']['size']</varname> will be - initialized (as well as in $HTTP_POST_FILES for PHP version - prior 4.1.0). + initialized (as well as in $HTTP_POST_FILES for PHP versions prior + to 4.1.0). When <literal>register_globals</literal> is on, globals for uploaded files are also initialized. Each of these will be a numerically @@ -392,7 +392,7 @@ <varname>$_FILES['userfile']['name'][1]</varname> would contain the value <filename>xwp.out</filename>. Similarly, <varname>$_FILES['userfile']['size'][0]</varname> would - contain <filename>review.html</filename>'s filesize, and so forth. + contain <filename>review.html</filename>'s file size, and so forth. </simpara> <simpara> <varname>$_FILES['userfile']['name'][0]</varname>, @@ -417,15 +417,15 @@ <![CDATA[ <?php /* PUT data comes in on the stdin stream */ -$putdata = fopen("php://stdin","r"); +$putdata = fopen("php://stdin", "r"); /* Open a file for writing */ -$fp = fopen("myputfile.ext","w"); +$fp = fopen("myputfile.ext", "w"); -/* Read the data 1kb at a time +/* Read the data 1 KB at a time and write to the file */ -while ($data = fread($putdata,1024)) - fwrite($fp,$data); +while ($data = fread($putdata, 1024)) + fwrite($fp, $data); /* Close the streams */ fclose($fp); @@ -479,7 +479,7 @@ <para> <informalexample><programlisting role="php"> <![CDATA[ -<?php copy($PHP_UPLOADED_FILE_NAME,$DOCUMENT_ROOT.$REQUEST_URI); ?> +<?php copy($PHP_UPLOADED_FILE_NAME, $DOCUMENT_ROOT . $REQUEST_URI); ?> ]]> </programlisting></informalexample> </para> @@ -488,7 +488,7 @@ client. You would probably want to perform some checks and/or authenticate the user before performing this file copy. The only trick here is that when PHP sees a PUT-method request it stores - the uploaded file in a temporary file just like those handled but + the uploaded file in a temporary file just like those handled by the <link linkend="features.file-upload.post-method">POST-method</link>. When the request ends, this temporary file is deleted. So, your