Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4236010
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: 嵌入式

2011-08-26 21:07:08

1. 安装 PEAR 中的HTTP_Upload

  1. root@ywx:/usr/local/php# ./bin/pear install HTTP_Upload
  2. downloading HTTP_Upload-0.9.1.tar ...
  3. Starting to download HTTP_Upload-0.9.1.tar (Unknown size)
  4. ..........done: 38,912 bytes
  5. install ok: channel://pear.php.net/HTTP_Upload-0.9.1
  6. root@ywx:/usr/local/php#

  7. root@ywx:/usr/local/php/lib/php/HTTP# ls
  8. Upload.php

test.html

  1. <form action="./test.php" method="post" enctype="multipart/form-data">
  2.     <input type="file" name="zuoye1"><br>
  3.     <input type="submit" value="submit notes" name="ok">
  4. </form>

test.php

  1. <?php
  2.     if(isset($_POST['ok']))
  3.     {
  4.         require_once 'HTTP/Upload.php';
  5.         $upload = new HTTP_Upload();
  6.         $file = $upload->getFiles('zuoye1');
  7.         if($file->isValid())
  8.         {
  9.             $file->moveTo('/usr/local/apache/htdocs/class/classnotes/');
  10.             echo "file successfully uploaded!!";    
  11.         }
  12.         else
  13.         {
  14.             echo $file->errorMsg();
  15.         }
  16.     }
  17. ?>




注意一点:

   在上传的文件中,一定要 内容,如果text.txt中没有内容,那么上传会错误。



阅读(1543) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~