php实现文件的上传和下载

推荐操作系统:windows7系统、PHP5.6、DELL G3电脑

1、上传文件

is_uploaded_file判断文件是否通过HTTPOST上传。

move_uploaded_file将上传的文件移动到新的位置。

设置前端上传界面

<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<title>Document</title>
</head>
<body>
<formaction="./doup.php"method="post"enctype="multipart/form-data">
<inputtype="file"name="file">
<inputtype="submit"value="上传">
</form>
</body>
</html>

2、下载文件

对于浏览器不识别的文件,可直接利用A连接下载或使用readfile函数。

a 连接下载实例。

<!--因为他们三个浏览器不认识这样的类型-->
<ahref="./downlist/1.rar">1.rar</a>
<ahref="./downlist/1.exe">1.exe</a>
<ahref="./downlist/1.avi">1.avi</a>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。