上传文件
- getdata.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>上传文件</title>
</head>
<body>
<form action="getfile.php" method="post" enctype="multipart/form-data">
<input type="file" name="upload">
<button>上传</button>
</form>
</body>
</html>
- getfile.php
<?php
//var_dump($_FILES['upload']);
$file=$_FILES['upload'];
$newname="img/".$file['name'];
if ($filr['error']==0) {
move_uploaded_file($file['tmp_name'],$newname);
}
?>
<img src="<?php echo $newname ?>" alt="这是图片">
- 运行截图