raful           Sat Jan 26 06:36:56 2002 EDT

  Added files:                 
    /phpdoc/he/features file-upload.xml 
  Log:
  first edition, you know...
  

Index: phpdoc/he/features/file-upload.xml
+++ phpdoc/he/features/file-upload.xml
<?xml version="1.0" encoding="iso-8859-8-i"?>
<!-- $Revision: 1.28 $ -->
 <chapter id="features.file-upload">
  <title>����� ������ �����</title>

  <sect1 id="features.file-upload.post-method">
   <title>POST method uploads</title>

   <simpara>
   PHP ����� ���� ����� ����� ������� ��� ����� ���� RFC-1867
   (����� �� netscape navigator 3 �����, microsoft internet explorer 3 ��
   ���� (patch) �� ���������, �� ������� ����� ���� ��� �����).
   ����'� ��� ����� ������ ������ �� ���� ���� ��� ����� ��������.
   �� ������ �� PHP ��������� ������ ������, ����� ����� ���� �� ��
   ������ ������ �� �����, ��� ����� �� ����� ���� ������.
   </simpara>
   <para>
   PHP �� ����� ����� ����� ������ PUT �-netscape composer ��������
   �� W3C, Amaya, ������� ��. ��� ����� �� <link
    linkend="features.file-upload.put-method">����� ����� PUT</link>.
   </para>
   <para>
   ��� ����� ���� ���� ������� �� ��� ����� ���� ����� ����� ���� ���:
    <example>
     <title>���� ����� ����</title>
     <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>
   �-_URL_ ���� ������ �� ���� PHP. ���� ����� MAX_FILE_SIZE ����
   ���� ���� ��� ���� �� ����� ����� ��� ���� ����� �������� ������.
   ����� ��� ������� ���� ���� (byte).
        <warning>
         <para>
   ����� �-MAX_FILE_SIZE ��� ���� ����� ������. �� ����� ������ ��
   �������� ���. ���� �� ����� �� �� ������� ����� �������! �� �����
   �-PHP ���� ����� ��������, ��� ���, �� ���� �����.
          The MAX_FILE_SIZE is advisory to the browser. It is easy to 
          circumvent this maximum. So don't count on it that the browser
          obeys you wish! The PHP-settings for maximum-size, however,
          cannot be fooled.
         </para>
        </warning>
   </para>

   <para>
   �-PHP, ������� ����� ���� ������� ������� ���� ���� ����� ����� �������,
   ����� �<link
    linkend="ini.register-globals">register_globals</link> �����
   �-<filename>php.ini</filename>.
   �� <link
    linkend="ini.track-vars">track_vars</link> �����, �� ���� ������ �-PHP ��
   ����� ������� <varname>$HTTP_POST_VARS</varname>. �� ���� �� ����� �������
   ����� �������� ����� ������ ���� ��� 'userfile', ��� ������ ������:

    <itemizedlist>
     <listitem>
      <simpara>
   <varname>$userfile</varname> - �� ����� ����� ��� ����� ����� ������ ����.
      </simpara>
     </listitem>
     <listitem>
      <simpara>
   <varname>$userfile_name</varname> - ��� �� ����� ������ �� ����� �� ����� �� �� 
����� �� �����
      </simpara>
     </listitem>
     <listitem>
      <simpara>
   <varname>$userfile_size</varname> - ����� �� ����� ������� �� ���� (byte)
      </simpara>
     </listitem>
     <listitem>
      <simpara>
   <varname>$userfile_type</varname> - �-mime type �� �����, ����� ������� ���� �� 
����� ���. �����: "image/gif".
      </simpara>
     </listitem>
    </itemizedlist>
   �� ���� �� ����� "$userfile" ��� ������ ��� ��� �� ��� ����
   �� �-TYPE=file ����� ����� �����. ����� ����� ����� ������
   ������, ����� ����� ����� ��� "userfile".
   </para>

   <para>
   �-PHP 4, �������� ���� �����, ��� ������ ������� <varname>$HTTP_POST_FILES</varname>
   ���� ����� ���� �� ����� ������. �� ���� �� �� <link 
linkend="ini.track-vars">track_vars</link>
   �����, ��� <link linkend="ini.track-vars">track_vars</link> ���� �����
   �������� PHP ���� ���� 4.0.2.
   </para>

   <para>
   ������ �� <varname>$HTTP_POST_FILES</varname> ������ ���. �� ���� ��
   ����� ����� ��� ��� ����� ������ ��� 'userfile', ��� ������ �����:
    <variablelist>
     <varlistentry>
      <term><varname>$HTTP_POST_FILES['userfile']['name']</varname></term>
      <listitem>
       <para>
   ��� ������ �� ����� �� ���� �����.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><varname>$HTTP_POST_FILES['userfile']['type']</varname></term>
      <listitem>
       <para>
   �-mime type �� �����, �� ������ ���� �� ����� ���. �����: 
<literal>"image/gif"</literal>.
        </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><varname>$HTTP_POST_FILES['userfile']['size']</varname></term>
      <listitem>
       <para>
   �����, ������� ���� (byte), �� ����� ������.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><varname>$HTTP_POST_FILES['userfile']['tmp_name']</varname></term>
      <listitem>
       <para>
        The temporary filename of the file in which the uploaded file
        was stored on the server.
   �� ����� ����� ��� ���� ����� �� ����.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>

   <para>
   ������ ����, ������ ����� ������� ������ ���� ����� ����� �� ����, ���
   �� ����� ���� �<link
    linkend="ini.upload-tmp-dir">upload_tmp_dir</link> ������
   �<filename>php.ini</filename>. ���� ����� �� ������ ����� ����� �� ���� �� ���
   ����� ����� ������ <envar>TMPDIR</envar> ������ �� PHP ���.
   ����� ������� <function>putenv</function> ���� ������ �� PHP �� �����.
   ��� ��, ����� ������ ��� ���� ����� ������ ������� ����� ������� �����
   ������� �� ����� ������.
    <example>
     <title>����� ����� �����</title>
     <para>
   �������� ����� �� ���� ������� �� PHP �������� �-3.0.16,
   �������� �������� �-PHP ������ 4.0.2. ���� ����� �� �� ��������
   <function>is_uploaded_file</function> �-<function>move_uploaded_file</function>.
     </para>
     <programlisting role="php">
<![CDATA[
<?php 
if (is_uploaded_file($userfile)) {
    copy($userfile, "/place/to/put/uploaded/file");
} else {
    echo "Possible file upload attack: filename '$userfile'.";
}
/* ...or... */
move_uploaded_file($userfile, "/place/to/put/uploaded/file");
?>
]]>
     </programlisting>
     <para>
   ���� ������� ������ �� PHP, ���� ����� ���� ��� ������.
      <note>
       <para>
   �� <emphasis>��</emphasis> ����� �������� �� PHP �������
   �-4.0.2. �� ���� ��������� ������� �� PHP ������ ���� ������ ���.
       </para>
      </note>
     </para>
     <programlisting role="php">
<![CDATA[
<?php
/* Userland test for uploaded file. */ 
function is_uploaded_file($filename) {
    if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
        $tmp_file = dirname(tempnam('', ''));
    }
    $tmp_file .= '/' . basename($filename);
    /* User might have trailing slash in php.ini... */
    return (ereg_replace('/+', '/', $tmp_file) == $filename);
}

if (is_uploaded_file($userfile)) {
    copy($userfile, "/place/to/put/uploaded/file");
} else {
    echo "Possible file upload attack: filename '$userfile'.";
}
?>
]]>
     </programlisting>
    </example>
   </para>
   <simpara>
   ������ �-PHP ����� �� ����� ������ ���� ����� �� ������ ������
   ��� ����� �� ���� ����� �� ����� ������. ����, ������, ������
   ������ <varname>$file_size</varname> ��� ����� �� ����, ��� ��
   ���� ����. ���� ������ ������ <varname>$file_type</varname> ���
   ����� �� ���� ��� ���� ��������� �� ��� ������. ���� �������
   ��� ����, ���� ����� �� ����� �������� ������, �� ������ ����
   ����� ���.
   </simpara>
   <simpara>
   ����� ���� �������� ������ ���� ����� �� ��� �� �����, �� ���� �� ����.
   </simpara>
  </sect1>
 
  <sect1 id="features.file-upload.common-pitfalls">
   <title>������� ������</title>
   <simpara>
   ������� <literal>MAX_FILE_SIZE</literal> �� ���� ������ ���� ����
   ����� ����� ����� ������ ������ �-ini - <link
    linkend="ini.upload-max-filesize">upload_max_filesize</link>.
   ����� ����� ��� 2 ���-����.
   </simpara>
   <simpara>
   ��� ����� ������ ������� ����, ������� ������ ����� ����� ����
   ������� �����.
   </simpara>
   <simpara>
    Please note that the CERN httpd seems to strip off everything
    starting at the first whitespace in the content-type mime header
    it gets from the client.  As long as this is the case, CERN httpd
    will not support the file upload feature.
   </simpara>
  </sect1>

  <sect1 id="features.file-upload.multiple">
   <title>����� ����� ������</title>
   <simpara>
   ���� ������ ��� ����� ��-�����, ������� ����� ���� ������� ������.
   ��� ����� �� ��, �� ������ ����� ����� ����� ���� ����� �-HTML ���
   ������ �� ����� ����� ��'�������:
   </simpara>
   <note>
    <para>
   ����� ������ ����� ������ ����� ������ 3.0.10.
    </para>
   </note>
   <para>
    <example>
     <title>����� ����� ������</title>
     <programlisting role="html">
<![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>
   <simpara>
   ������� ������ ����, ������� <varname>$userfile</varname>,
   <varname>$userfile_name</varname> �-<varname>$userfile_size</varname>
   ������ ����� ������� (��� ��� �-$HTTP_POST_FILES
   ($HTTP_POST_VARS �-PHP 3)). �� ��� ���"� ������, ����� ������, ����
   �� ������ ��������, ��� ������ ������.
   </simpara>
   <simpara>
   ������, ����� ������� <filename>/home/test/review.html</filename>
   �-<filename>/home/test/xwp.out</filename> �����. ����� ���,
   <varname>$userfile_name[0]</varname> ���� �� ����
   <filename>review.html</filename>, �-<varname>$userfile_name[1]</varname>
   ���� �� ���� <filename>xwp.out</filename>. ����� �����,
   <varname>$userfile_size[0]</varname> ���� �� ���� �����
   <filename>review.html</filename> ������ ���.
   </simpara>
   <simpara>
   <varname>$userfile['name'][0]</varname>, 
<varname>$userfile['tmp_name'][0]</varname>,
   <varname>$userfile['size'][0]</varname> �-<varname>$userfile['type'][0]</varname>
   �� �� ������.
   </simpara>
  </sect1>

  <sect1 id="features.file-upload.put-method">
   <title>����� ����� PUT</title>

   <para>
   PHP ����� ����� ����� HTTP PUT ��� ������� netscape composer �-W3C Amaya.
   ���� PUT ������ ���� ������ �����, ��� ����� ���� ���:
    <informalexample>
     <programlisting>
PUT /path/filename.html HTTP/1.1
     </programlisting>
    </informalexample>
   </para>
   <para>
   ���� ��� �� ����� ������ ���� ����� �� ����� ��� ����, ���:
   /path/filename.html ��� ���� ���. ���� ����� ��� �� ����� ���
   ���� Apache �� PHP ���� ����� ����� ������� ����� �� ����� ������
   ��� ���� ���. ��� ���� ������ ����, ���� ����� ���� �������
   ������ ����� ���� ������� PHP. �� Apache ���� ���� �� ���
   ������ <emphasis>Script</emphasis>. ���� ���� �� �� ���� ��� ����
   ����� ������������ �� Apache. ���� ���� ��� ���� �����
   &lt;Directory&gt;�� ���� ���� ����� &lt;Virtualhost&gt;.
   ���� ��� ���� �� �����:
    <informalexample>
     <programlisting>
Script PUT /put.php
     </programlisting>
    </informalexample>
   </para>
   <simpara>
   �� ���� �-Apache ����� �� �� ����� PUT �-URI ����� �� ������ �� ����
   �� ����� ������� �� ����� ������� put.php. �� �����, �����, �-PHP ������
   ������ .php ��-PHP �����.
   </simpara>
   <simpara>
   ���� ����� put.php ���� ����� ���� ���:
   </simpara>
   <para>
    <informalexample><programlisting role="php">
<![CDATA[
<?php copy($PHP_UPLOADED_FILE_NAME,$DOCUMENT_ROOT.$REQUEST_URI); ?>
]]>
    </programlisting></informalexample>
   </para>
   <simpara>
   �� ����� �� ����� ������ ������ �� ��� �����. ��� ������ �� ����� ����
   ��� ������ �/�� ���� �� ������ ���� ����� ����� �����.  ����� �����
   ��� ��� ���-PHP ���� ����� ����� PUT, ��� ������ �� ����� ������
   ����� ���� ��� ��� ��� ������ ����
   <link linkend="features.file-upload.post-method">���� POST</link>.
   ������� �������, ����� ����� ��� ����. ���, ������ �-PHP ����� �-PUT
   ���� ������ �� ����� ������ �����. �� ����� �� ����� ����� ���� ����
   ������ $PHP_PUT_FILENAME, ����� ����� �� �� ����� ����� ����
   $REQUEST_URI (���� ������� �� ����� ����� Apache). �� ����� �����
   ��� �� ������ �����. ����� ���� ���� ��� �����. ��� ����,
   ������, ������ �� �� ������ ������ ������� ������ ������.
   </simpara>
  </sect1>

 </chapter>

<!-- 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
indent-tabs-mode:nil
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
-->

Reply via email to