【发布时间】:2012-03-30 20:56:54
【问题描述】:
我需要将服务器端 php.ini 的配置(参数是 allow_url_fopen)从 off 更改为 on,但我无权访问 php.ini 文件,我想通过 php 代码来完成,但我不知道 wat怎么做以及在哪里粘贴该代码(我应该把它放在我用来下载文件的标题之前吗???)
header('Content-disposition: attachment; filename=' . basename($fileName));
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Description: File Transfer');
ob_clean();
flush();
readfile($finalFileName);
exit;
提前感谢
【问题讨论】:
-
php.ini 文件在运行时由 webserver/apache 解析。如果您的主机不允许该功能或安全模式已打开,那么您无法更改它。我不确定您的代码示例与 allow_url_fopen 有什么关系,如果它是本地的,您可能不需要该功能,您是否考虑过使用 curl 检索文件,大多数主机允许 curl
-
默认情况下 allow_url_fopen 是打开的,但如果它被主机关闭,那么它可能是被禁止的,另一个解决方案是将 php.ini 放在你的根目录中并根据需要进行更改。我在我的一些图形解决方案中使用了它并且确实有效。祝你好运
标签: php