0

I'm trying to read a txt file with a controller that i've set up. However, I'm unsure where to place this file and how to call it correctly. Everything i've tried has resulted in the following error:

2015-01-21T13:57:02+00:00 ERR (3): Warning: file_get_contents(youtube_videos_only_hash.txt): failed to open stream: No such file or directory in /opt/magento/app/code/local/namespace/module/controllers/IndexController.php on line 9

Any help would be appreciated.

The error in question is related to the filepath:

    $filepath = 'images/youtube_videos_only_hash.txt';
    $hashes2 = file_get_contents($filepath);
easymoden00b
  • 1,277
  • 2
  • 26
  • 55

1 Answers1

1

Save file in var/youtube_videos_only_hash.txt and try this:

$path = Mage::getBaseDir('var') . DS . 'youtube_videos_only_hash.txt';
$hashes2 = file_get_contents($path);
Lord Skeletor
  • 4,038
  • 1
  • 16
  • 19