A-A+

php实现文件下载

2016年02月29日 PHP 暂无评论 阅读 1,422 views 次

使用PHP实现文件下载,需要使用header头来指定下载文件类型,不知道下载文件类型可以使用application/octet-stream 二进制流方式来代替

 

<?php

header("Content-type: application/octet-stream");

header('Content-Disposition: attachment; filename=test.png');

header("Content-Length: " . filesize($file));

readfile($file);

?>

给我留言

Copyright © 严佳冬 保留所有权利.   Theme  Ality 百度地图 苏ICP备19045515号-2

用户登录

分享到: