嗨,我需要帮助,我正在使用来自php.net的以下代码,以允许网站访问者在我的网站上下载文档
<?php
$file = $_GET['file'];;
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>我的问题是,代码不是输出一个对话框以便我保存/下载这里概述的文档,而是在一个新页面中打开,显示异常的data...the代码在xampp localhost上运行良好,但不能在服务器上运行。
可能的问题是什么?
发布于 2014-04-19 12:52:23
代码看起来很完美。我认为php.ini在服务器和xampp中的配置可能是不同的。
我的建议是在服务器和xampp中运行<?php phpinfo(); ?>,比较配置并与服务器中的xampp配置相匹配。
https://stackoverflow.com/questions/23165978
复制相似问题