当前位置:编程学习 > php >>

PHP文件上传问题

PHP如何通过POST上传txt文件并下载txt而不是直接在网页中打开
答案:<form action="fil1e.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" size="30" style="height:19px; font-size:14px"/>
<input name="adds" type="submit" style="height:20px; font-size:12px" value="导入" />
</form>
fil1e.php:
$nn="update/";  //所放文件夹位置
$name=$nn.basename($_FILES['file']['name']);//文件夹名+上传文件名
 move_uploaded_file($_FILES['file']['tmp_name'],$name);//将上传文件移动到该位置

txt下载:
$filename="update/文件名";
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($filename));
readfile($filename);

群号 壹3壹4597壹2  大家一起讨论.

上一个:PHP与ASP有什么不同?
下一个:php 数据删除问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,