cvs: phpdoc-zh /reference/filesystem/functions is-uploaded-file.xml
| From: | liuming | Date: | Sun, 14 Aug 2005 14:49:54 +0000 |
| Subject: | cvs: phpdoc-zh /reference/filesystem/functions is-uploaded-file.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-2260@lists.php.net to get a copy of this message | ||
lm92 Sun Aug 14 10:49:54 2005 EDT
Modified files:
/phpdoc-zh/reference/filesystem/functions is-uploaded-file.xml
Log:
updated to en version
http://cvs.php.net/diff.php/phpdoc-zh/reference/filesystem/functions/is-uploaded-file.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc-zh/reference/filesystem/functions/is-uploaded-file.xml
diff -u phpdoc-zh/reference/filesystem/functions/is-uploaded-file.xml:1.3
phpdoc-zh/reference/filesystem/functions/is-uploaded-file.xml:1.4
--- phpdoc-zh/reference/filesystem/functions/is-uploaded-file.xml:1.3 Wed Apr 23 19:58:53 2003
+++ phpdoc-zh/reference/filesystem/functions/is-uploaded-file.xml Sun Aug 14 10:49:53 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="gb2312"?>
-<!-- $Revision: 1.3 $ -->
-<!-- $Author: dallas $ -->
-<!-- EN-Revision: 1.3 Maintainer: dallas Status: ready -->
+<!-- $Revision: 1.4 $ -->
+<!-- $Author: lm92 $ -->
+<!-- EN-Revision: 1.6 Maintainer: dallas Status: ready -->
<refentry id="function.is-uploaded-file">
<refnamediv>
<refname>is_uploaded_file</refname>
@@ -22,6 +22,29 @@
ÕâÖÖ¼ì²éÏԵøñÍâÖØÒª£¬Èç¹ûÉÏ´«µÄÎļþÓпÉÄÜ»áÔì³É¶ÔÓû§»ò±¾ÏµÍ³µÄÆäËûÓû§ÏÔʾÆäÄÚÈݵϰ¡£
</para>
<para>
+ ΪÁËÄÜʹ <function>is_uploaded_file</function>
º¯ÊýÕý³£¹¤×÷£¬±Ø¶ÎÖ¸¶¨ÀàËÆÓÚ
+ $_FILES['userfile']['tmp_name']
µÄ±äÁ¿£¬¶øÔÚ´Ó¿Í»§¶ËÉÏ´«µÄÎļþÃû
+ $_FILES['userfile']['name'] ²»ÄÜÕý³£ÔË×÷¡£
+ </para>
+ <example>
+ <title><function>is_uploaded_file</function> Àý×Ó</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ echo "File ". $_FILES['userfile']['name'] ." uploaded
successfully.\n";
+ echo "Displaying contents\n";
+ readfile($_FILES['userfile']['tmp_name']);
+} else {
+ echo "Possible file upload attack: ";
+ echo "filename '". $_FILES['userfile']['tmp_name'] .
"'.";
+}
+
+?>]]>
+ </programlisting>
+ </example>
+ <para>
<function>is_uploaded_file</function> ½ö¿ÉÓÃÓÚ
PHP 3 µÄ 3.0.16 °æÖ®ºó£¬ÒÔ¼° PHP 4 µÄ 4.0.2
°æÖ®ºó¡£Èç¹ûÄãÖ´ÒâÒªÓÃÀϰ汾£¬¿ÉÒÔÓÃÏÂÃæµÄº¯ÊýÀ´±£»¤×Ô¼º£º
@@ -31,11 +54,15 @@
PHP 4 µÄ 4.0.2 °æÖ®ºó¡£ËüÒÀÀµµÄ PHP
ÄÚ²¿º¯ÊýÔڸð汾֮ºó¸Ä±äÁË¡£
</para>
</note>
+ </para>
+ <example>
+ <title><function>is_uploaded_file</function> ¿ÉÔËÐÐÓÚ PHP 4
< 4.0.3 µÄÀý×Ó</title>
<programlisting role="php">
<![CDATA[
<?php
/* Userland test for uploaded file. */
-function is_uploaded_file($filename) {
+function is_uploaded_file($filename)
+{
if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
$tmp_file = dirname(tempnam('', ''));
}
@@ -54,7 +81,7 @@
?>
]]>
</programlisting>
- </para>
+ </example>
<para>
²Î¼û <function>move_uploaded_file</function>£¬ÒÔ¼°<link
linkend="features.file-upload">ÎļþÉÏ´«´¦Àí</link>Ò»ÕÂÖеļòµ¥Ê¹ÓÃÀý×Ó¡£