goba Sun Aug 19 09:20:43 2001 EDT
Modified files:
/phpdoc/en/features file-upload.xml
Log:
. The best place to show how <![CDATA[ ... ]]> can help...
. Converting all HTML tags to lowecased ones
. Using correct <filename> instead of other bad ones
. Adding role="html" to HTML example
Index: phpdoc/en/features/file-upload.xml
diff -u phpdoc/en/features/file-upload.xml:1.23 phpdoc/en/features/file-upload.xml:1.24
--- phpdoc/en/features/file-upload.xml:1.23 Sun Aug 19 07:09:16 2001
+++ phpdoc/en/features/file-upload.xml Sun Aug 19 09:20:42 2001
@@ -1,5 +1,5 @@
<?xml encoding="iso-8859-1"?>
-<!-- $Revision: 1.23 $ -->
+<!-- $Revision: 1.24 $ -->
<chapter id="features.file-upload">
<title>Handling file uploads</title>
@@ -26,12 +26,14 @@
looks something like this:
<example>
<title>File Upload Form</title>
- <programlisting>
-<FORM ENCTYPE="multipart/form-data" ACTION="_URL_"
METHOD="POST">
-<INPUT TYPE="hidden" name="MAX_FILE_SIZE"
value="1000">
-Send this file: <INPUT NAME="userfile" TYPE="file">
-<INPUT TYPE="submit" VALUE="Send File">
-</FORM>
+ <programlisting role="html">
+<![CDATA[
+<form enctype="multipart/form-data" action="_URL_" method="post">
+<input type="hidden" name="MAX_FILE_SIZE" value="1000">
+Send this file: <input name="userfile" type="file">
+<input type="submit" value="Send File">
+</form>
+]]>
</programlisting>
</example>
The _URL_ should point to a PHP file. The MAX_FILE_SIZE hidden
@@ -81,14 +83,14 @@
<simpara>
<varname>$userfile_type</varname> - The mime type of the file
if the browser provided this information. An example would be
- "image/gif".
+ "image/gif".
</simpara>
</listitem>
</itemizedlist>
- Note that the "$userfile" part of the above variables is
+ Note that the "$userfile" part of the above variables is
whatever the name of the INPUT field of TYPE=file is in the upload
form. In the above upload form example, we chose to call it
- "userfile"
+ "userfile"
</para>
<para>
@@ -119,7 +121,7 @@
<para>
The mime type of the file, if the browser provided this
information. An example would be
- <literal>"image/gif"</literal>.
+ <literal>"image/gif"</literal>.
</para>
</listitem>
</varlistentry>
@@ -163,7 +165,8 @@
<function>move_uploaded_file</function>.
</para>
<programlisting role="php">
-<?php
+<![CDATA[
+<?php
if (is_uploaded_file($userfile)) {
copy($userfile, "/place/to/put/uploaded/file");
} else {
@@ -171,7 +174,8 @@
}
/* ...or... */
move_uploaded_file($userfile, "/place/to/put/uploaded/file");
-?>
+?>
+]]>
</programlisting>
<para>
For earlier versions of PHP, you'll need to do something like
@@ -185,7 +189,8 @@
</note>
</para>
<programlisting role="php">
-<?php
+<![CDATA[
+<?php
/* Userland test for uploaded file. */
function is_uploaded_file($filename) {
if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
@@ -202,6 +207,7 @@
echo "Possible file upload attack: filename '$userfile'.";
}
?>
+]]>
</programlisting>
</example>
</para>
@@ -226,8 +232,7 @@
<title>Common Pitfalls</title>
<simpara>
The <literal>MAX_FILE_SIZE</literal> item cannot specify a file size
- greater than the file
- size that has been set in the <link
+ greater than the file size that has been set in the <link
linkend="ini.upload-max-filesize">upload_max_filesize</link> ini-setting.
The default is 2 Megabytes.
</simpara>
@@ -260,12 +265,14 @@
<example>
<title>Uploading multiple files</title>
<programlisting role="html">
-<form action="file-upload.php" method="post"
enctype="multipart/form-data">
- Send these files:<br>
- <input name="userfile[]" type="file"><br>
- <input name="userfile[]" type="file"><br>
- <input type="submit" value="Send files">
-</form>
+<![CDATA[
+<form action="file-upload.php" method="post" enctype="multipart/form-data">
+ Send these files:<br>
+ <input name="userfile[]" type="file"><br>
+ <input name="userfile[]" type="file"><br>
+ <input type="submit" value="Send files">
+</form>
+]]>
</programlisting>
</example>
</para>
@@ -283,10 +290,10 @@
<filename>/home/test/review.html</filename> and
<filename>/home/test/xwp.out</filename> are submitted. In this
case, <varname>$userfile_name[0]</varname> would
- contain the value <literal>review.html</literal>,
+ contain the value <filename>review.html</filename>,
and <varname>$userfile_name[1]</varname> would
contain the value
- <varname>xwp.out</varname>. Similarly,
+ <filename>xwp.out</filename>. Similarly,
<varname>$userfile_size[0]</varname> would contain
<filename>review.html</filename>'s filesize, and so forth.
</simpara>
@@ -339,7 +346,9 @@
</simpara>
<para>
<informalexample><programlisting>
-<?php copy($PHP_UPLOADED_FILE_NAME,$DOCUMENT_ROOT.$REQUEST_URI); ?>
+<![CDATA[
+<?php copy($PHP_UPLOADED_FILE_NAME,$DOCUMENT_ROOT.$REQUEST_URI); ?>
+]]>
</programlisting></informalexample>
</para>
<simpara>