php 强制下载文件实现代码

yipeiwu_com6年前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生成Flash动画的实现代码

PHP生成Flash动画的实现代码

其中有一组映射到 SWF 动画中的数据类型的对象:子图形、图形、文本、位图等等。在本文中,我使用了预编译的扩展 php_ming.dll 库用于 Windows 版本的 PHP。 清单...

php中将数组存到文件里的实现代码

第一次分享代码;(写得很烂..紧张纳紧张纳) php的数组十分强大,有些数据不存入数据库直接写到文件上,用的时候直接require。 (实际中有用到把数组存在到文件中的功能,不过分享的代...

php中的登陆login

login <?php require "../include/DBClass.php"; $username=$_POST['UserName']; $password...

Yii2框架整合Xunsearch搜索引擎的方法

本文实例讲述了Yii2框架整合Xunsearch搜索引擎的方法。分享给大家供大家参考,具体如下: 公司一直用的YII2框架,然后要做一个中文搜索引擎,所有想的Xunsearch这个项目,...

PHP之生成GIF动画的实现方法

代码如下所示:复制代码 代码如下:<?class GifMerge {     var $ver    &nb...