Home > Backend Development > PHP Tutorial > php 文件上载 输出文件

php 文件上载 输出文件

WBOY
Release: 2016-06-13 12:59:44
Original
951 people have browsed it

php 文件下载 输出文件
我看网上有关 输出文件的

有用 readfile

有用 
           $fp = fopen($filepath, 'rb');
             fpassthru($fp);
            fclose($fp);

这都是一次性输出


但是 我还看到了一个  分段输出的  每次输出1024字节

$fp= fopen($this->path,"r");
$buffer_size = $this->buffer_size; //这个值是1024
$cur_pos = 0;
while(!feof($fp) && $file_size>$buffer_size+$cur_pos){
$buffer = fread($fp,$buffer_size); 
echo $buffer;
$cur_pos += $buffer_size;
}

$buffer = fread($fp,$file_size-$cur_pos);
   echo $buffer;
   fclose($fp); 

我想问   分段输出  和 一次性输出 有啥区别呀  (不考虑断点续传的情况下)
------解决方案--------------------
撇开其他因素,显然一次读取要比分段读取所用的内存要多
------解决方案--------------------

该回复于2012-12-25 11:09:57被管理员删除
------解决方案--------------------
假设下载的是个游戏光盘的iso文件,大小在4G以上……
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template