cvs: peardoc /en/package http.xml /en/package/http http-upload.xml /en/package/http/http-upload examples.xml i18n.xml information.xml intro.xml
| From: | Martin Jansen | Date: | Wed, 07 Sep 2005 18:40:02 +0000 |
| Subject: | cvs: peardoc /en/package http.xml /en/package/http http-upload.xml /en/package/http/http-upload examples.xml i18n.xml information.xml intro.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-6738@lists.php.net to get a copy of this message | ||
mj Wed Sep 7 14:40:02 2005 EDT
Added files:
/peardoc/en/package/http http-upload.xml
/peardoc/en/package/http/http-upload examples.xml i18n.xml
information.xml intro.xml
Modified files:
/peardoc/en/package http.xml
Log:
* Added preliminary documentation for HTTP_Upload.
http://cvs.php.net/diff.php/peardoc/en/package/http.xml?r1=1.8&r2=1.9&ty=u Index: peardoc/en/package/http.xml diff -u peardoc/en/package/http.xml:1.8 peardoc/en/package/http.xml:1.9 --- peardoc/en/package/http.xml:1.8 Thu Jul 15 05:13:36 2004 +++ peardoc/en/package/http.xml Wed Sep 7 14:40:01 2005 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <chapter id="package.http"> <title>HTTP</title> @@ -17,6 +17,7 @@ &package.http.http-client; &package.http.http-download; &package.http.http-request; + &package.http.http-upload; </chapter> <!-- Keep this comment at the end of the file http://cvs.php.net/co.php/peardoc/en/package/http/http-upload.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload.xml +++ peardoc/en/package/http/http-upload.xml <!-- $Revision: 1.1 $ --> <sect1 id="package.http.http-upload"> <title>HTTP_Upload</title> <para> Easy and secure managment of files submitted via <acronym>HTML</acronym> forms. </para> &package.http.http-upload.intro; &package.http.http-upload.examples; &package.http.http-upload.information; &package.http.http-upload.i18n; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/examples.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/examples.xml +++ peardoc/en/package/http/http-upload/examples.xml <!-- $Revision: 1.1 $ --> <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. </para> <example> <title>Simple file upload</title> <para> 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> <programlisting role="php"> require_once "HTTP/Upload.php"; $upload = new HTTP_Upload("en"); $file = $upload->getFiles("f"); if ($file->isValid()) { $moved = $file->moveTo("uploads/"); if (!PEAR::isError($moved)) { echo "File was moved to uploads/"; } } </programlisting> </example> <example id="package.http.http-upload.examples.multiple"> <title>Multiple files, more extensive checks</title> <para> Multiple files can uploaded by replacing the name of the form field (<literal>f</literal>) with <literal>f[]</literal> and creating multiple <literal><input /></literal> fields with this name. </para> <programlisting role="php"> $upload = new HTTP_Upload("en"); $files = $upload->getFiles(); foreach($files as $file){ if (PEAR::isError($file)) { echo $file->getMessage(); } if ($file->isValid()) { $file->setName("uniq"); $dest_name = $file->moveTo("uploads/"); if (PEAR::isError($dest_name)) { echo $dest_name->getMessage(); } $real = $file->getProp("real"); } elseif ($file->isMissing()) { echo "No file was provided."; } elseif ($file->isError()) { echo $file->errorMsg(); } print_r($file->getProp()); } </programlisting> </example> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/i18n.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/i18n.xml +++ peardoc/en/package/http/http-upload/i18n.xml <!-- $Revision: 1.1 $ --> <sect2 id="package.http.http-upload.i18n"> <title>Internationalized Error Messages</title> <para> Another handy feature of <classname>HTTP_Upload</classname> is support of internationalized error messages. This means that in case an error (like an invalid file upload) is detected, the programmer can choose in which the language the error messages should be return from <classname>HTTP_Upload</classname>. </para> <para> The first parameter of the constructor method for <classname>HTTP_Upload</classname> determines the language to be used. This is illustrated in the following example: </para> <example> <title>Example</title> <programlisting role="php"> // German error messages $language = "de"; require_once "HTTP/Upload.php"; $upload = new HTTP_Upload($language); $file = $upload->getFiles("f"); if ($file->isValid()) { $moved = $file->moveTo("uploads/"); if (!PEAR::isError($moved)) { echo "File was moved to uploads/"; } else { // This will print a german error message echo "An error was detected: " . $moved->getMessage() . "<br />"; } } </programlisting> </example> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/information.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/information.xml +++ peardoc/en/package/http/http-upload/information.xml <!-- $Revision: 1.1 $ --> <sect2 id="package.http.http-upload.information"> <title>Extensive information about uploaded files</title> <para> <classname>HTTP_Upload</classname> provides extensive information about uploaded files via the <function>getProp</function> method: <funcsynopsis> <funcprototype> <funcdef> mixed <function>HTTP_Upload_File::getProp</function> </funcdef> <paramdef> <parameter>[name]</parameter> </paramdef> </funcprototype> </funcsynopsis> </para> <para> If no value for <parameter>name</parameter> is provided, then this method will return an array containing all available information about the uploaded file. Otherwise the information identified by the value of this parameter will be returned as a string. </para> <example> <title>Extensive information via <function>getProp</function></title> <programlisting role="php"> require_once "HTTP/Upload.php"; $upload = new HTTP_Upload("en"); $file = $upload->getFiles("f"); if ($file->isValid()) { echo "<pre>"; print_r($file->getProp()); echo "</pre>"; printf("The uploaded file has the extension %s.", $file->getProp("ext")); } </programlisting> </example> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/intro.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/intro.xml +++ peardoc/en/package/http/http-upload/intro.xml <!-- $Revision: 1.1 $ --> <sect2 id="package.http.http-upload.intro"> <title>Introduction</title> <para> This package provides an advanced system for managing uploads of files via <acronym>HTML</acronym> <literal><input type="file" /></literal> fields. Features include: </para> <itemizedlist> <listitem> <simpara> <link linkend="package.http.http-upload.examples.multiple"> Handling of multiple file uploads at a time </link> </simpara> </listitem> <listitem> <simpara> Safe file copying/moving from temporary directories </simpara> </listitem> <listitem> <simpara> Upload validaton mechanisms </simpara> </listitem> <listitem> <simpara> <link linkend="package.http.http-upload.information"> Extensive information about uploaded files </link> </simpara> </listitem> <listitem> <simpara> Renaming uploaded files </simpara> </listitem> <listitem> <simpara> <link linkend="package.http.http-upload.i18n">Internationalized error messages</link> </simpara> </listitem> </itemizedlist> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
http://cvs.php.net/diff.php/peardoc/en/package/http.xml?r1=1.8&r2=1.9&ty=u Index: peardoc/en/package/http.xml diff -u peardoc/en/package/http.xml:1.8 peardoc/en/package/http.xml:1.9 --- peardoc/en/package/http.xml:1.8 Thu Jul 15 05:13:36 2004 +++ peardoc/en/package/http.xml Wed Sep 7 14:40:01 2005 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <chapter id="package.http"> <title>HTTP</title> @@ -17,6 +17,7 @@ &package.http.http-client; &package.http.http-download; &package.http.http-request; + &package.http.http-upload; </chapter> <!-- Keep this comment at the end of the file http://cvs.php.net/co.php/peardoc/en/package/http/http-upload.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload.xml +++ peardoc/en/package/http/http-upload.xml <!-- $Revision: 1.1 $ --> <sect1 id="package.http.http-upload"> <title>HTTP_Upload</title> <para> Easy and secure managment of files submitted via <acronym>HTML</acronym> forms. </para> &package.http.http-upload.intro; &package.http.http-upload.examples; &package.http.http-upload.information; &package.http.http-upload.i18n; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/examples.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/examples.xml +++ peardoc/en/package/http/http-upload/examples.xml <!-- $Revision: 1.1 $ --> <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. </para> <example> <title>Simple file upload</title> <para> 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> <programlisting role="php"> require_once "HTTP/Upload.php"; $upload = new HTTP_Upload("en"); $file = $upload->getFiles("f"); if ($file->isValid()) { $moved = $file->moveTo("uploads/"); if (!PEAR::isError($moved)) { echo "File was moved to uploads/"; } } </programlisting> </example> <example id="package.http.http-upload.examples.multiple"> <title>Multiple files, more extensive checks</title> <para> Multiple files can uploaded by replacing the name of the form field (<literal>f</literal>) with <literal>f[]</literal> and creating multiple <literal><input /></literal> fields with this name. </para> <programlisting role="php"> $upload = new HTTP_Upload("en"); $files = $upload->getFiles(); foreach($files as $file){ if (PEAR::isError($file)) { echo $file->getMessage(); } if ($file->isValid()) { $file->setName("uniq"); $dest_name = $file->moveTo("uploads/"); if (PEAR::isError($dest_name)) { echo $dest_name->getMessage(); } $real = $file->getProp("real"); } elseif ($file->isMissing()) { echo "No file was provided."; } elseif ($file->isError()) { echo $file->errorMsg(); } print_r($file->getProp()); } </programlisting> </example> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/i18n.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/i18n.xml +++ peardoc/en/package/http/http-upload/i18n.xml <!-- $Revision: 1.1 $ --> <sect2 id="package.http.http-upload.i18n"> <title>Internationalized Error Messages</title> <para> Another handy feature of <classname>HTTP_Upload</classname> is support of internationalized error messages. This means that in case an error (like an invalid file upload) is detected, the programmer can choose in which the language the error messages should be return from <classname>HTTP_Upload</classname>. </para> <para> The first parameter of the constructor method for <classname>HTTP_Upload</classname> determines the language to be used. This is illustrated in the following example: </para> <example> <title>Example</title> <programlisting role="php"> // German error messages $language = "de"; require_once "HTTP/Upload.php"; $upload = new HTTP_Upload($language); $file = $upload->getFiles("f"); if ($file->isValid()) { $moved = $file->moveTo("uploads/"); if (!PEAR::isError($moved)) { echo "File was moved to uploads/"; } else { // This will print a german error message echo "An error was detected: " . $moved->getMessage() . "<br />"; } } </programlisting> </example> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/information.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/information.xml +++ peardoc/en/package/http/http-upload/information.xml <!-- $Revision: 1.1 $ --> <sect2 id="package.http.http-upload.information"> <title>Extensive information about uploaded files</title> <para> <classname>HTTP_Upload</classname> provides extensive information about uploaded files via the <function>getProp</function> method: <funcsynopsis> <funcprototype> <funcdef> mixed <function>HTTP_Upload_File::getProp</function> </funcdef> <paramdef> <parameter>[name]</parameter> </paramdef> </funcprototype> </funcsynopsis> </para> <para> If no value for <parameter>name</parameter> is provided, then this method will return an array containing all available information about the uploaded file. Otherwise the information identified by the value of this parameter will be returned as a string. </para> <example> <title>Extensive information via <function>getProp</function></title> <programlisting role="php"> require_once "HTTP/Upload.php"; $upload = new HTTP_Upload("en"); $file = $upload->getFiles("f"); if ($file->isValid()) { echo "<pre>"; print_r($file->getProp()); echo "</pre>"; printf("The uploaded file has the extension %s.", $file->getProp("ext")); } </programlisting> </example> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/http/http-upload/intro.xml?r=1.1&p=1 Index: peardoc/en/package/http/http-upload/intro.xml +++ peardoc/en/package/http/http-upload/intro.xml <!-- $Revision: 1.1 $ --> <sect2 id="package.http.http-upload.intro"> <title>Introduction</title> <para> This package provides an advanced system for managing uploads of files via <acronym>HTML</acronym> <literal><input type="file" /></literal> fields. Features include: </para> <itemizedlist> <listitem> <simpara> <link linkend="package.http.http-upload.examples.multiple"> Handling of multiple file uploads at a time </link> </simpara> </listitem> <listitem> <simpara> Safe file copying/moving from temporary directories </simpara> </listitem> <listitem> <simpara> Upload validaton mechanisms </simpara> </listitem> <listitem> <simpara> <link linkend="package.http.http-upload.information"> Extensive information about uploaded files </link> </simpara> </listitem> <listitem> <simpara> Renaming uploaded files </simpara> </listitem> <listitem> <simpara> <link linkend="package.http.http-upload.i18n">Internationalized error messages</link> </simpara> </listitem> </itemizedlist> </sect2> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->