开发者

Why wont my filesize() method work?

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 $lesso开发者_开发知识库nDescription;        
    $arrLessonVocabulary = array();
    $arrLessonVocabulary = file("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt");

    if (arrLessonVocabulary == NULL)
        print "Error - vocabulary5.txt cannot be opened";
?>


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜