Page 1 of 1

how to Get file from another server and save it

Posted: Thu Dec 12, 2002 4:00 am
by haixiao
how to Get file from another server and save it on running server ?
for example i want to save http://site.com/info.zip to my sever.

Posted: Thu Dec 12, 2002 11:02 am
by Traduim
You may use FTP functions (http://www.php.net/ftp), or fopen() http://www.php.net/fopen.

i get it

Posted: Thu Dec 12, 2002 10:41 pm
by haixiao
<?

function copyFromRemote($remote,$local){
$fp1 = fopen($remote,"rb");
$fp2 = fopen($local,"wb");

while(!feof($fp1)) {
$line = fread($fp1,500000);
fputs($fp2,$line,strlen($line));
}
}
copyFromRemote("http://localhost/test/4.jpg","c:/temp/4.jpg");
?>