我需要通过 PHP 复制一些大文件 (6 GB)。我怎样才能做到这一点?
Copy()
函数做不到。
我在 Windows 32/64 上使用 PHP 5.3。
最佳答案
应该这样做。
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));
}
fclose($fin);
fclose($fout);
return $ret; # return number of bytes written
}
关于php - 在 PHP 中复制大文件(超过 2 GB),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6564643/