Reputation: 1610
Why wont my filesize()
method work? My path works for the fread()
and file()
methods, but it wont acknowledge the path on filesize()
. Why not? What should my correct path be?
<?php
$strLessonDescription = fopen("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/lesson5.txt", "r")
or die ("Error - lesson5.txt cannot be opened");
$lessonDescription = fread($strLessonDescription,
filesize("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt"));
fclose($strLessonDescription);
echo $lessonDescription;
$arrLessonVocabulary = array();
$arrLessonVocabulary = file("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt");
if (arrLessonVocabulary == NULL)
print "Error - vocabulary5.txt cannot be opened";
?>
Upvotes: 0
Views: 205
Reputation: 1835
Since the file you're trying to read is via a remote request, rather than local file, it significantly changes how you want to read that data. Per the fread() manual page, you need to read the file in chunks. Alternatively, try using file_get_contents() which should simplify your code:
$lessonDescription = file_get_contents('http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt');
echo $lessonDescription;
Upvotes: 5