Help Inspire
Help Inspire

Reputation: 366

Force Download of Files with PHP

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

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

I am not sure how to correct these errors to get it working. Any help would be greatly appreciated. Thank you.

Upvotes: 0

Views: 349

Answers (2)

Rudu
Rudu

Reputation: 15892

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__

The timezone message can be fixed with an php.ini entry:

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

Or by adding date_default_timezone_set to the top of your PHP document:

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

Upvotes: 1

null
null

Reputation: 11869

The first warning is about usage of certain date function. In this case, I think that warning itself activates it (it stores it in log). The server warning is more important, it mentions usage of undefined magic constant __DIR__ (current script directory). It was introduces in PHP 5.3.

So, you have two options.

  1. Update to PHP 5.3 5.4
  2. Replace __DIR__ with dirname(__FILE__).

Upvotes: 0

Related Questions