Jump to content


Photo

Why can't I read this file?


  • Please log in to reply
2 replies to this topic

#1 jkies00

jkies00
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 September 2006 - 10:09 PM

Hello,

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

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

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

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 05 September 2006 - 11:48 PM


Try:

<?php

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

?>

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

#3 jkies00

jkies00
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 06 September 2006 - 10:15 AM

Still nothing.  Would it matter that my $dir variable is coming from an array?

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users