Pear HTTP_Upload文件上传库
1. 安装 PEAR 中的HTTP_Upload
root@ywx:/usr/local/php# ./bin/pear install HTTP_Upload
downloading HTTP_Upload-0.9.1.tar ...
Starting to download HTTP_Upload-0.9.1.tar (Unknown size)
..........done: 38,912 bytes
install ok: channel://pear.php.net/HTTP_Upload-0.9.1
root@ywx:/usr/local/php#
root@ywx:/usr/local/php/lib/php/HTTP# ls
Upload.php
test.html
<form action="./test.php" method="post" enctype="multipart/form-data"> <input type="file" name="zuoye1"><br> <input type="submit" value="submit notes" name="ok"> </form>
test.php
<?php if(isset($_POST['ok'])) { require_once 'HTTP/Upload.php'; $upload = new HTTP_Upload(); $file = $upload->getFiles('zuoye1'); if($file->isValid()) { $file->moveTo('/usr/local/apache/htdocs/class/classnotes/'); echo "file successfully uploaded!!"; } else { echo $file->errorMsg(); } }
永久地址:http://www.phprm.com/code/Pear-HTTP_Upload.html
转载随意~请带上教程地址吧^^