At 16:56 19.11.2002, Michelle spoke out and said: --------------------[snip]-------------------- >I would like to download a word-document from another site and save it to my >harddrive. >How would I go about doing this? > >I tried: ><?php >$filename = "http://host.com/document.doc; > >$fd = fopen ($filename, "rb"); >$string = fread ($fd, filesize ($filename)); <----ERROR >fclose ($fd); --------------------[snip]--------------------
From the docs (http://www.php.net/manual/en/function.filesize.php): This function will not work on remote files; the file to be examined must be accessible via the server's filesystem. You can bypass this by reading until EOF: <?php $filename = 'http://host.com/document.doc'; $fd = fopen($filename, 'rb'); $string = null; while ($chunk = fread($fd, 64*128)) // read blocks at 64 k $string .= $chunk; fclose($fd); ?> Untested but it should work as expected. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/