mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
A bit xml-reworking, removed some tabs to satisfy Derick, added
upload_max_filesize ini directive. Someone should check the last one, I didn't mention the default, and apparently 2M is also supported... but I needed to get rid of the jade-error. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@51125 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
88a68c5633
commit
2b6750adf4
3 changed files with 447 additions and 423 deletions
File diff suppressed because it is too large
Load diff
|
@ -35,15 +35,23 @@ Send this file: <INPUT NAME="userfile" TYPE="file">
|
|||
The _URL_ should point to a PHP file. The MAX_FILE_SIZE hidden
|
||||
field must precede the file input field and its value is the
|
||||
maximum filesize accepted. The value is in bytes.
|
||||
<warning>
|
||||
<para>
|
||||
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>
|
||||
In PHP 3, the following variables will be defined within the
|
||||
In PHP, the following variables will be defined within the
|
||||
destination script upon a successful upload, assuming that <link
|
||||
linkend="ini.register-globals">register_globals</link> is turned
|
||||
on in <filename>php3.ini</filename>. If <link
|
||||
on in <filename>php.ini</filename>. If <link
|
||||
linkend="ini.track-vars">track_vars</link> is turned on, they will
|
||||
also be available in PHP 3 within the global array
|
||||
also be available in PHP within the global array
|
||||
<varname>$HTTP_POST_VARS</varname>. Note that the following
|
||||
variable names assume the use of the file upload name 'userfile',
|
||||
as used in the example above:
|
||||
|
@ -215,9 +223,10 @@ if (is_uploaded_file($userfile)) {
|
|||
<sect1 id="features.file-upload.common-pitfalls">
|
||||
<title>Common Pitfalls</title>
|
||||
<simpara>
|
||||
The MAX_FILE_SIZE item cannot specify a file size greater than the file
|
||||
size that has been set in the upload_max_filesize in the PHP 3.ini file
|
||||
or the corresponding php3_upload_max_filesize Apache .conf directive.
|
||||
The <literal>MAX_FILE_SIZE</literal> item cannot specify a file size
|
||||
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>
|
||||
<simpara>
|
||||
|
@ -232,7 +241,7 @@ if (is_uploaded_file($userfile)) {
|
|||
</simpara>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="feature-fileupload.multiple">
|
||||
<sect1 id="features.file-upload.multiple">
|
||||
<title>Uploading multiple files</title>
|
||||
<simpara>
|
||||
It is possible to upload multiple files simultaneously and have
|
||||
|
@ -248,7 +257,7 @@ if (is_uploaded_file($userfile)) {
|
|||
<para>
|
||||
<example>
|
||||
<title>Uploading multiple files</title>
|
||||
<programlisting>
|
||||
<programlisting role="html">
|
||||
<form action="file-upload.php" method="post" enctype="multipart/form-data">
|
||||
Send these files:<br>
|
||||
<input name="userfile[]" type="file"><br>
|
||||
|
@ -260,9 +269,9 @@ if (is_uploaded_file($userfile)) {
|
|||
</para>
|
||||
<simpara>
|
||||
When the above form is submitted, the arrays
|
||||
<computeroutput>$userfile</computeroutput>,
|
||||
<computeroutput>$userfile_name</computeroutput>, and
|
||||
<computeroutput>$userfile_size</computeroutput> will be formed in
|
||||
<varname>$userfile</varname>,
|
||||
<varname>$userfile_name</varname>, and
|
||||
<varname>$userfile_size</varname> will be formed in
|
||||
the global scope (as well as in $HTTP_POST_FILES ($HTTP_POST_VARS
|
||||
in PHP 3)). Each of these will be a numerically indexed array of
|
||||
the appropriate values for the submitted files.
|
||||
|
@ -271,19 +280,19 @@ if (is_uploaded_file($userfile)) {
|
|||
For instance, assume that the filenames
|
||||
<filename>/home/test/review.html</filename> and
|
||||
<filename>/home/test/xwp.out</filename> are submitted. In this
|
||||
case, <computeroutput>$userfile_name[0]</computeroutput> would
|
||||
contain the value <computeroutput>review.html</computeroutput>,
|
||||
and <computeroutput>$userfile_name[1]</computeroutput> would
|
||||
case, <varname>$userfile_name[0]</varname> would
|
||||
contain the value <literal>review.html</literal>,
|
||||
and <varname>$userfile_name[1]</varname> would
|
||||
contain the value
|
||||
<computeroutput>xwp.out</computeroutput>. Similarly,
|
||||
<computeroutput>$userfile_size[0]</computeroutput> would contain
|
||||
<varname>xwp.out</varname>. Similarly,
|
||||
<varname>$userfile_size[0]</varname> would contain
|
||||
<filename>review.html</filename>'s filesize, and so forth.
|
||||
</simpara>
|
||||
<simpara>
|
||||
<computeroutput>$userfile['name'][0]</computeroutput>,
|
||||
<computeroutput>$userfile['tmp_name'][0]</computeroutput>,
|
||||
<computeroutput>$userfile['size'][0]</computeroutput>, and
|
||||
<computeroutput>$userfile['type'][0]</computeroutput> are also set.
|
||||
<varname>$userfile['name'][0]</varname>,
|
||||
<varname>$userfile['tmp_name'][0]</varname>,
|
||||
<varname>$userfile['size'][0]</varname>, and
|
||||
<varname>$userfile['type'][0]</varname> are also set.
|
||||
</simpara>
|
||||
</sect1>
|
||||
|
||||
|
@ -313,18 +322,18 @@ PUT /path/filename.html HTTP/1.1
|
|||
a <Virtualhost> block. A line like this would do the trick:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
Script PUT /put.php3
|
||||
Script PUT /put.php
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<simpara>
|
||||
This tells Apache to send all PUT requests for URIs that match the
|
||||
context in which you put this line to the put.php3 script. This
|
||||
assumes, of course, that you have PHP enabled for the .php3
|
||||
context in which you put this line to the put.php script. This
|
||||
assumes, of course, that you have PHP enabled for the .php
|
||||
extension and PHP is active.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Inside your put.php3 file you would then do something like this:
|
||||
Inside your put.php file you would then do something like this:
|
||||
</simpara>
|
||||
<para>
|
||||
<informalexample><programlisting>
|
||||
|
|
|
@ -22,10 +22,10 @@ disable_functions =
|
|||
When safe_mode is on, PHP checks to see if the owner of the current script
|
||||
matches the owner of the file to be operated on by a file function. For
|
||||
example:
|
||||
<computeroutput>
|
||||
<programlisting role="ls">
|
||||
-rw-rw-r-- 1 rasmus rasmus 33 Jul 1 19:20 script.php
|
||||
-rw-r--r-- 1 root root 1116 May 26 18:01 /etc/passwd
|
||||
</computeroutput>
|
||||
</programlisting>
|
||||
Running this script.php
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
|
@ -33,10 +33,10 @@ disable_functions =
|
|||
?>
|
||||
</programlisting>
|
||||
results in this error when safe mode is enabled:
|
||||
<computeroutput>
|
||||
<programlisting role="php">
|
||||
Warning: SAFE MODE Restriction in effect. The script whose uid is 500 is not
|
||||
allowed to access /etc/passwd owned by uid 0 in /docroot/script.php on line 2
|
||||
</computeroutput>
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
If instead of safe_mode, you set an open_basedir directory then all file
|
||||
|
@ -49,10 +49,10 @@ php_admin_value open_basedir /docroot
|
|||
</programlisting>
|
||||
If you run the same script.php with this open_basedir setting then this is
|
||||
the result:
|
||||
<computeroutput>
|
||||
<programlisting role="php">
|
||||
Warning: open_basedir restriction in effect. File is in wrong directory in
|
||||
/docroot/script.php on line 2
|
||||
</computeroutput>
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
You can also disable individual functions. If we add this to our php.ini
|
||||
|
@ -61,9 +61,10 @@ Warning: open_basedir restriction in effect. File is in wrong directory in
|
|||
disable_functions readfile,system
|
||||
</programlisting>
|
||||
Then we get this output:
|
||||
<computeroutput>
|
||||
Warning: readfile() has been disabled for security reasons in /docroot/script.php on line 2
|
||||
</computeroutput>
|
||||
<programlisting role="php">
|
||||
Warning: readfile() has been disabled for security reasons in
|
||||
/docroot/script.php on line 2
|
||||
</programlisting>
|
||||
</para>
|
||||
</chapter>
|
||||
|
||||
|
|
Loading…
Reference in a new issue