繁体   English   中英

使用PHP强制下载文件

[英]Force Download of Files with PHP

我的PHP知识有限,我正在尝试将http://www.tutorialchip.com/php-download-file-script/这个脚本实施到我的网站中。 我已经在http://brooksmemories.com/test/上将其文件原封不动地推送了。 如果单击文件,则会出现以下错误

Strict Standards: main() [function.main]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead in /home/inspire/public_html/brooksmemories.com/test/download.php on line 16

Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /home/inspire/public_html/brooksmemories.com/test/download.php on line 16

我不确定如何更正这些错误以使其正常运行。 任何帮助将不胜感激。 谢谢。

检查您的PHP版本... __DIR__是仅在PHP 5.3+中可用的新常量,在旧版本的PHP中实现相同的方法是: dirname(__FILE__)代替__DIR__

时区消息可以通过php.ini条目进行修复:

;approx line 1005
[Date]
date.timezone = "America/Chicago";

或通过将date_default_timezone_set添加到PHP文档的顶部:

<?php
date_default_timezone_set('America/Chicago');
//...

第一个警告是关于某些日期功能的使用。 在这种情况下,我认为警告本身会激活它(将其存储在日志中)。 服务器警告更为重要,它提到了未定义的魔术常数__DIR__ (当前脚本目录)的用法。 它是在PHP 5.3中引入的。

因此,您有两个选择。

  1. 更新到PHP 5.3 5.4
  2. __DIR__替换为dirname(__FILE__)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM