手机
当前位置:查字典教程网 >编程开发 >php教程 >php 强制下载文件实现代码
php 强制下载文件实现代码
摘要:复制代码代码如下:?

复制代码 代码如下:

<?php

$file = 'monkey.gif';

if (file_exists($file)) {

header('Content-Description: File Transfer');

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment; filename='.basename($file));

header('Content-Transfer-Encoding: binary');

header('Expires: 0');

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Pragma: public');

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

ob_clean();

flush();

readfile($file);

exit;

}

?>

?

<?php

header("Content-Type: application/force-download");

header("Content-Disposition: attachment; filename=ins.jpg");

readfile("imgs/test_Zoom.jpg");

?>

【php 强制下载文件实现代码】相关文章:

php.ini中文版

无限级别菜单的实现

php生成年月日下载列表的方法

php实现读取和写入tab分割的文件

php使用cookie实现记住登录状态

文件上传的实现

用php实现gb2312和unicode间的编码转换

PHP4中实现动态代理

PHP实现远程下载文件到本地

php数组合并与拆分实例分析

精品推荐
分类导航