首页 > PHP > PHP 在线输出PDF文件

PHP 在线输出PDF文件

<?php

if(!function_exists(‘read_pdf’)) {

function read_pdf($file) {

if(strtolower(substr(strrchr($file,’.’),1)) != ‘pdf’) {

echo ‘文件格式不对.’;

return;

}

if(!file_exists($file)) {

echo ‘文件不存在’;

return;

}

header(‘Content-type: application/pdf’);

header(‘filename=’.$file);

readfile($file);

}

}

/*End of PHP*/

分类:PHP 标签:,
  1. 还没有评论。
  1. No trackbacks yet.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: