文件上传和下载

move_upload_file()文件上传处理函数

header()和readfile()可以实现文件的下载

文件下载

<?php

 $textname='goods/test.txt';//原文件,需要下载的文件

$newname= 'index.txt';//新文件名,下载下来的文件名

header("Content-type:text/plain");//设置下载文件的类型

header("Content-Length:".filesize($textname));//设置下载文件的大小

header("Content-Disposition:attachment;filename=$newname");//设置下载文件名

readfile($textname);

?>

file_exists()判断文件是否存在

unlike()删除不需要的文件

copy()复制文件,

move_upload_file()移动文件

rename()移动,并可以给一个新名字

rewind()重置文件

ftell()报告文件的指针位置

fseek()移动指针文件

 

posted @ 2018-06-16 17:05  magical宇  阅读(95)  评论(0编辑  收藏  举报