faqts : Computers : Programming : Languages : PHP : Function Libraries

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

49 of 80 people (61%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I copy a remote file without going through the fopen, fputs stuff?
How can I copy a remote file?
How can I copy a remote binary file?
what if I'm behind a proxy, how do i do the fopen then?

Aug 8th, 1999 23:08
Nathan Wallace, unknown unknown, Sacul, Tomas Vorobjov, Robert Aden


You have to use fopen and fputs to copy a remote file:

    function copyFromRemote($remote,$local){
        $fp1 = fopen($remote,"r");
        $fp2 = fopen($local,"w");

        while(!feof($fp1)) {
            $line = fgets($fp1, 1024);
            fputs($fp2,$line,strlen($line));
        } 
    }

I think that would work but i haven't tested it .....

U should use the following for binary files:

$line = fread($fp1,1024);