PHP - 使用pear的HTTP_Upload包进行上传

前台代码:

<html>
<head>
    <title>上传文件</title>
</head>
<body>
    <form enctype="multipart/form-data" action="upload.php" method="post">
        <input type="file" name="uploadfile" />
        <input type="submit" value="上传"/>
    </form>
</body>
</html>

 

后台代码:

<?php 
    
    //上传单文件
    require 'HTTP/Upload.php';
   
    $upload = new HTTP_Upload();
    
    $file = $upload->getFiles('uploadfile');
    
    if ($file->isValid()) {
        $file->moveTo('uploads/');
        echo 'OK!';
    }else {
        echo 'False!';
    }
    
?>

 


最终:

posted on 2015-11-23 12:18  ultrastrong  阅读(339)  评论(0编辑  收藏  举报