手机
当前位置:查字典教程网 >编程开发 >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遍历CSV类实例

php.ini中文版

无限级别菜单的实现

php实现图片转换成ASCII码的方法

php的控制语句

写一段简单的PHP建立文件夹代码

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

php判断文本文档字符编码

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

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

精品推荐
分类导航