Jump to content

Archived

This topic is now archived and is closed to further replies.

jkies00

Why can't I read this file?

Recommended Posts

Hello,

I've opened a directory, and I'm trying to read a text file, but I can't get it to read:

[code]
$subFolders = opendir($dir); 
$myfile = "info.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, 5);
fclose($fh);
echo $theData;
[/code]

The directory I've opened does contain the info.txt file I'm looking for.  I'm able to view it if I list the contents of the folder.  Why can't I read it?  The above code returns no output.

~jeff

Share this post


Link to post
Share on other sites

Try:

[code]<?php

  $myfile = file('info.txt');

  print_r($myfile);

?>[/code]

See if you can get he contents of the array to output.

Share this post


Link to post
Share on other sites
Still nothing.  Would it matter that my $dir variable is coming from an array?

[code]
$dir = $dirArray[0];
$subFolders = opendir($dir); 
$myfile = file('info.txt');
print_r($myfile);
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.