At 21:05 27.11.2002, Steve Keller spoke out and said:
--------------------[snip]--------------------
>I'm still trying to get a file posted to another server, but I seem to have 
>run across an odd snag, and I was hoping someone can point out where I've 
>gone wrong. Here's the code:
>
><?
>         $data = "mtype=XMLDOC&outfile=true";
>         $dataFile = 
>"http://www.healthtvchannel.org/courses/pay/data/test.xml";;
>         $fileSize = filesize($dataFile);
>         $fp = fopen($dataFile, "rb");
>         $strFile = fread($fp, $fileSize);
>         fclose($fp);
--------------------[snip]-------------------- 

You can't stat() a remote file - filesize() only works with local filesystems.

However you do not need to know the size of the file to read it - simply do
it in chunks:
        $dataFile = "http://www.healthtvchannel.org/courses/pay/data/test.xml";;
        $fp = fopen($dataFile, "rb");
         $strFile = null;
         while ($chunk = fread($fp, 524288))  // 512 kB chunks modify as needed
              $strFile .= $chunk;
        fclose($fp);

HTH,

-- 
   >O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
    ^ http://www.vogelsinger.at/

Reply via email to