|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <!-- $Revision$ --> |
3 | | -<!-- $Author$ --> |
4 | | -<!-- EN-Revision: fc174e8d6162091550edde46159917ee7e5a2e73 Maintainer: Gregory Status: ready --> |
5 | | -<!-- CREDITS: dallas, Luffy --> |
| 3 | +<!-- EN-Revision: 04d9aded7bbd447523cf038ddf88e6d7f7e43c53 Maintainer: Gregory Status: ready --> |
| 4 | +<!-- CREDITS: dallas, Luffy, mowangjuanzi --> |
6 | 5 | <chapter xml:id="features.file-upload" xmlns="http://docbook.org/ns/docbook"> |
7 | 6 | <title>文件上传处理</title> |
8 | 7 |
|
@@ -456,36 +455,30 @@ Script PUT /put.php |
456 | 455 | <simpara> |
457 | 456 | 这将告诉 Apache 将所有对 URI 的 PUT 请求全部发送到 <filename>put.php</filename> 脚本,这些 |
458 | 457 | URI 必须和 PUT 命令中的内容相匹配。当然,这是建立在 PHP 支持 |
459 | | - <filename>.php</filename> 扩展名,并且 PHP 已经在运行的假设之上。 |
460 | | - The destination resource for all PUT |
461 | | - requests to this script has to be the script itself, not a filename the |
462 | | - uploaded file should have. |
| 458 | + <filename class="extension">.php</filename> 扩展名,并且 PHP 已经在运行的假设之上。此脚本的所有 |
| 459 | + PUT 请求的目标资源必须是脚本本身,而不是上传文件本身的文件名。 |
463 | 460 | </simpara> |
464 | 461 | <simpara> |
465 | | - With PHP you would then do something like the following in |
466 | | - your put.php. This would copy the contents of the uploaded file to the |
467 | | - file <filename>myputfile.ext</filename> on the server. |
468 | | - You would probably want to perform some checks and/or |
469 | | - authenticate the user before performing this file copy. |
| 462 | + 使用 PHP,可以在 put.php 中执行类似下面的操作。这会将上传文件的内容复制到服务器上的文件 |
| 463 | + <filename>myputfile.ext</filename>。在执行此文件复制之前,可能会希望执行一些检查并且验证用户身份。 |
470 | 464 | </simpara> |
471 | 465 | <para> |
472 | 466 | <example> |
473 | 467 | <title>保存 HTTP PUT 文件</title> |
474 | 468 | <programlisting role="php"> |
475 | 469 | <![CDATA[ |
476 | 470 | <?php |
477 | | -/* PUT data comes in on the stdin stream */ |
| 471 | +/* PUT 数据来自于 stdin 流 */ |
478 | 472 | $putdata = fopen("php://input", "r"); |
479 | 473 |
|
480 | | -/* Open a file for writing */ |
| 474 | +/* 打开要写入的文件 */ |
481 | 475 | $fp = fopen("myputfile.ext", "w"); |
482 | 476 |
|
483 | | -/* Read the data 1 KB at a time |
484 | | - and write to the file */ |
| 477 | +/* 每次读取 1KB 的数据并写入到文件 */ |
485 | 478 | while ($data = fread($putdata, 1024)) |
486 | 479 | fwrite($fp, $data); |
487 | 480 |
|
488 | | -/* Close the streams */ |
| 481 | +/* 关闭流 */ |
489 | 482 | fclose($fp); |
490 | 483 | fclose($putdata); |
491 | 484 | ?> |
|
0 commit comments