working - php transfer large file between servers

Copy large files(over 2 GB) in PHP (4)

I would copy it X byte by X byte (several megs each iteration).
X will be the most optimized size which depends on your machine.
And I would do it not through the web server but as a stand alone script, run through cron or one time call to it (cli).

I need to copy some big file (6 GB) via PHP. How can I do that? The Copy() function can't do it.

I am using PHP 5.3 on Windows 32/64.

Recent versions of PHP copy files with chunks so today you could use php copy() function safely

This should do it.

function chunked_copy($from, $to) {
    # 1 meg at a time, you can adjust this.
    $buffer_size = 1048576; 
    $ret = 0;
    $fin = fopen($from, "rb");
    $fout = fopen($to, "w");
    while(!feof($fin)) {
        $ret += fwrite($fout, fread($fin, $buffer_size));
    return $ret; # return number of bytes written