[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: "Greg Beaver" <cellog () php ! net>
Date: 2007-03-19 3:24:09
Message-ID: cvscellog1174274649 () cvsserver
[Download RAW message or body]
cellog Mon Mar 19 03:24:09 2007 UTC
Modified files:
/peardoc/en/package/http/http-upload examples.xml
Log:
add an example html form for each PHP example,
add *real* error handling to the simple example
http://cvs.php.net/viewvc.cgi/peardoc/en/package/http/http-upload/examples.xml?r1=1.1&r2=1.2&diff_format=u
Index: peardoc/en/package/http/http-upload/examples.xml
diff -u peardoc/en/package/http/http-upload/examples.xml:1.1 \
peardoc/en/package/http/http-upload/examples.xml:1.2
--- peardoc/en/package/http/http-upload/examples.xml:1.1 Wed Sep 7 18:40:01 2005
+++ peardoc/en/package/http/http-upload/examples.xml Mon Mar 19 03:24:09 2007
@@ -1,14 +1,39 @@
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<sect2 id="package.http.http-upload.examples">
<title>Examples</title>
<para>
In the following examples it is assumed that you are using an
<acronym>HTML</acronym> form field <literal><input type="file" name="f" \
/></literal>
- in order to upload files.
+ in order to upload files. For example:
</para>
<example>
+ <title>HTML form for simple file upload</title>
+ <para>
+ The following form can be used in order to test the single file upload example.
+ </para>
+ <programlisting role="html">
+<![CDATA[
+<?php
+// sample code from below goes here
+?>
+<html>
+ <head>
+ </head>
+ <body>
+ <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" />
+ </form>
+ </body>
+</html>
+]]>
+ </programlisting>
+ </example>
+
+ <example>
<title>Simple file upload</title>
<para>
@@ -18,6 +43,7 @@
</para>
<programlisting role="php">
+<![CDATA[
require_once "HTTP/Upload.php";
$upload = new HTTP_Upload("en");
@@ -27,11 +53,45 @@
$moved = $file->moveTo("uploads/");
if (!PEAR::isError($moved)) {
echo "File was moved to uploads/";
+ } else {
+ echo $moved->getMessage();
}
+} elseif ($file->isMissing()) {
+ echo "No file was provided.";
+} elseif ($file->isError()) {
+ echo $file->errorMsg();
}
+]]>
</programlisting>
</example>
+
+ <example>
+ <title>HTML form for multiple file upload</title>
+ <para>
+ The following form can be used in order to test the multiple file upload \
example. + </para>
+ <programlisting role="html">
+<![CDATA[
+<?php
+// sample code from below goes here
+?>
+<html>
+ <head>
+ </head>
+ <body>
+ <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" />
+ <input type="submit" name="submit" value="Submit" />
+ </form>
+ </body>
+</html>
+]]>
+ </programlisting>
+ </example>
+
<example id="package.http.http-upload.examples.multiple">
<title>Multiple files, more extensive checks</title>
@@ -43,6 +103,7 @@
</para>
<programlisting role="php">
+<![CDATA[
$upload = new HTTP_Upload("en");
$files = $upload->getFiles();
@@ -69,6 +130,7 @@
print_r($file->getProp());
}
+]]>
</programlisting>
</example>
</sect2>
--
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