文件上传

2011-02-13 阅读 40
<pre class="brush:php;">    <?php
//处理上传文件的核心代码
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        $name = $_FILES["pictures"]["name"][$key];
        move_uploaded_file($tmp_name, "./data/$name");
    }
}
?>
<html>
<head>
<meta http-equiv="content-type" content="html/text;charset=utf8"/head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="submit" value="Send" />
</p>
</form>
</body>
</html>

```

文件上传

更新于 2023年03月28日