[prev in list] [next in list] [prev in thread] [next in thread]
List: pear-doc
Subject: [PEAR-DOC] cvs: peardoc /en/package/http/http-upload examples.xml
From: "Christian Weiske" <cweiske () php ! net>
Date: 2008-11-17 20:22:34
Message-ID: cvscweiske1226953354 () cvsserver
[Download RAW message or body]
cweiske Mon Nov 17 20:22:34 2008 UTC
Modified files:
/peardoc/en/package/http/http-upload examples.xml
Log:
Fix doc Bug #7861: Filenames with spaces in them get their names
changed when being moved
http://cvs.php.net/viewvc.cgi/peardoc/en/package/http/http-upload/examples.xml?r1=1.4&r2=1.5&diff_format=u
Index: peardoc/en/package/http/http-upload/examples.xml
diff -u peardoc/en/package/http/http-upload/examples.xml:1.4 \
peardoc/en/package/http/http-upload/examples.xml:1.5
--- peardoc/en/package/http/http-upload/examples.xml:1.4 Thu Oct 9 15:16:38 2008
+++ peardoc/en/package/http/http-upload/examples.xml Mon Nov 17 20:22:34 2008
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<section xmlns="http://docbook.org/ns/docbook" version="lillet" \
xml:id="package.http.http-upload.examples"><info><title>Examples</title></info>
-
+<section
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:phd="http://www.php.net/ns/phd"
+ version="lillet"
+ xml:id="package.http.http-upload.examples"
+>
+ <info>
+ <title>Examples</title>
+ </info>
+
<para>
In the following examples it is assumed that you are using an
@@ -9,7 +17,7 @@
</para>
<example><info><title>HTML form for simple file upload</title></info>
-
+
<para>
The following form can be used in order to test the single file upload example.
</para>
@@ -22,7 +30,7 @@
<head>
</head>
<body>
- <form name="fileuploadexample" method="POST" enctype="multipart/form-data"
+ <form name="fileuploadexample" method="post" enctype="multipart/form-data"
action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>">
<input type="file" name="f" />
<input type="submit" name="submit" value="Submit" />
@@ -33,11 +41,13 @@
</programlisting>
</example>
- <example><info><title>Simple file upload</title></info>
-
+ <example>
+ <info>
+ <title>Simple file upload</title>
+ </info>
<para>
- The following code looks at the request and checks if a valid
+ The following code looks at the request and checks if a valid
file was uploaded through the form. If that is the case, the
file is moved to the subdirectory <filename>uploads</filename>.
</para>
@@ -50,9 +60,9 @@
$file = $upload->getFiles("f");
if ($file->isValid()) {
- $moved = $file->moveTo("uploads/");
+ $moved = $file->moveTo('uploads/');
if (!PEAR::isError($moved)) {
- echo "File was moved to uploads/";
+ echo 'File was moved to uploads/' . $file->getProp('name');
} else {
echo $moved->getMessage();
}
@@ -63,11 +73,28 @@
}
]]>
</programlisting>
+
+ <note>
+ <para>
+ Internally,
+ <phd:pearapi phd:package="HTTP_Upload" phd:linkend="HTTP_Upload_File::moveTo"/>
+ calls
+ <literal>$file-><phd:pearapi phd:package="HTTP_Upload" \
phd:linkend="HTTP_Upload_File::setName">setName</phd:pearapi>('safe');</literal> + \
which replaces + special characters in the name with an underscore.
+ You should always use
+ <literal>$file-><phd:pearapi phd:package="HTTP_Upload" \
phd:linkend="HTTP_Upload_File::getProp">getProp</phd:pearapi>('name')</literal> + \
after moving to retrieve the new filename. + </para>
+ </note>
</example>
- <example><info><title>HTML form for multiple file upload</title></info>
-
+ <example>
+ <info>
+ <title>HTML form for multiple file upload</title>
+ </info>
+
<para>
The following form can be used in order to test the multiple file upload \
example. </para>
@@ -80,7 +107,7 @@
<head>
</head>
<body>
- <form name="fileuploadexample2" method="POST" enctype="multipart/form-data"
+ <form name="fileuploadexample2" method="post" enctype="multipart/form-data"
action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>">
<input type="file" name="f1" />
<input type="file" name="f2" />
@@ -93,7 +120,7 @@
</example>
<example xml:id="package.http.http-upload.examples.multiple"><info><title>Multiple \
files, more extensive checks</title></info>
-
+
<para>
Multiple files can uploaded by replacing the name of the form
--
PEAR Documentation List Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic