复制代码 代码如下:
zuojiankuohaophpcn?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;
}
?>
以上代码是下载代码
接下来贴一段在线预览pdf文件的代码
复制代码 代码如下:
<?php
public function fddaction()
{
// get attachment location
$attachment_location = $_server["document_root"] . "/pdf/fdd/sample.pdf";
if (file_exists($attachment_location)) {
// attachment exists
// send open pdf dialog to user
header('cache-control: public'); // needed for i.e.
header('content-type: application/pdf');
header('content-disposition: inline; filename="sample.pdf"');
readfile($attachment_location);
die(); // stop execution of further script because we are only outputting the pdf
} else {
die('error: file not found.');
}
}
?>
QCMS企业建站系统是通过MVC架构开发的一套PHP轻量级系统,开源,小巧,易用,功能强大、可以自定义模块,容易二次开发,可以称得上是万能CMS系统,可用于企业站,文章站,图片站,下载站,你只要能想得到,就能做的到。 QCMS V6.0.0 主要功能描述特色说明: 简单易用的模板标签,是我们系统的核心组成部分,系统对SEO更友好,源代码全部开放,毫无保留! 1 内容模块有 ,新
0
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号