PHP远程下载大文件方法,防止内存溢出

<?php

set_time_limit(0);

$hostfile = fopen("https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box", 'r');
$fh = fopen("centos-7.0-x86_64.box", 'w');

while (!feof($hostfile)) {
    $output = fread($hostfile, 8192);
    fwrite($fh, $output);
}

fclose($hostfile);
fclose($fh);
官方文档链接:http://php.net/manual/zh/ref.curl.php

猜你喜欢

转载自blog.csdn.net/gaoxuaiguoyi/article/details/79029054
今日推荐