我已使用以下代码生成zip
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
这段代码可以正常工作,但是由于未知原因,直到我尝试为止
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
echo file_get_contents($zip_name);
我很好奇这两种情况的发生
Readfile会将文件直接读取到输出缓冲区中,而file_get_contents会将文件加载到内存中,当您回显结果时,将有效地将数据从内存复制到输出缓冲区中,是读取文件的2倍。
本文地址:http://php.askforanswer.com/php-readfileyufile_get_contents.html
文章标签:filesystems , function , php , readfile
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
文章标签:filesystems , function , php , readfile
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
评论已关闭!