使用PHP强制下载文件 [英] Force Download of Files with PHP
问题描述
我的PHP知识有限,我正在尝试实施 http:// www。 tutorialchip.com/php-download-file-script/ 这个脚本进入我的网站。我在 http://brooksmemories.com/test/ 中将文件保持不变。如果单击一个文件,我会收到以下错误
My PHP knowledge is limited and I am trying to implement http://www.tutorialchip.com/php-download-file-script/ this script into my site. I have pushed up their files unchanged here http://brooksmemories.com/test/. If a file is clicked I get the following errors
严格标准:main()[function.main]:依赖它是不安全的系统的时区设置。请使用date.timezone设置,TZ环境变量或date_default_timezone_set()函数。如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符。我们在第16行的/home/inspire/public_html/brooksmemories.com/test/download.php中选择'America / Chicago'代表'CDT / -5.0 / DST'
注意:使用未定义的常量__DIR__ - 在第16行的/home/inspire/public_html/brooksmemories.com/test/download.php中假定为__DIR__
我不确定如何纠正这些错误以使其正常工作。任何帮助将不胜感激。谢谢。
I am not sure how to correct these errors to get it working. Any help would be greatly appreciated. Thank you.
推荐答案
检查你的PHP版本...... __ DIR __
是一个仅在PHP 5.3+中可用的新常量,在旧版本的PHP中实现相同的方法是: dirname(__ FILE __)
代替 __DIR __
Check your PHP version... __DIR__
is a new constant only available in PHP 5.3+, the way to achieve the same in older versions of PHP was with: dirname(__FILE__)
in place of __DIR__
可以使用php.ini条目修复时区消息:
The timezone message can be fixed with an php.ini entry:
;approx line 1005
[Date]
date.timezone = "America/Chicago";
或者添加 date_default_timezone_set
到PHP文档的顶部:
Or by adding date_default_timezone_set
to the top of your PHP document:
<?php
date_default_timezone_set('America/Chicago');
//...
这篇关于使用PHP强制下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!