dongzhun8449
dongzhun8449
2011-02-15 21:04

下载大文件并在本地编写

  • php

which is the best way to download from php large files without consuming all server's memory?

I could do this (bad code):

$url='http://server/bigfile';
$cont = file_get_contents($url);
file_put_contents('./localfile',$cont);

This example loads entry remote file in $cont and this could exceed memory limit.

Is there a safe function (maybe built-in) to do this (maybe stream_*)?

Thanks

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换