php 中的简单文件上传
时间:2024-12-05
浏览:211
作者:佚名
来到golang学习网的大家,相信都是编程学习爱好者,希望在这里学习文章相关编程知识。下面本篇文章就来带大家聊聊《php 中的简单文件上传》,介绍一下,希望对大家的知识积累有所帮助,助力实战开发!

html 表单
/index.html :
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>document</title>
</head>
<body>
<form method="post" action="upload.php" enctype="multipart/form-data">
<label for="file-label">file : </label>
<input type="file" name="myfile" id="myfile" />
<input type="submit" name="submit" id="submit" value="submit" />
</form>
</body>
</html>
文件上传处理程序
/upload.php :
<?php $tempFile = $_FILES['myfile']['tmp_name']; $fileName = $_FILES['myfile']['name']; $fileDestination = __DIR__."/uploads/".$fileName; copy($tempFile, $fileDestination); unlink($tempFile);
注意:
必须事先创建 /uploads 文件夹。
到这里,我们也就讲完了《php 中的简单文件上传》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.20
11.20
11.20
11.20
热门专题
