php实现切割合并文件

发布时间:2018-10-13 14:00:55 作者:Aoe Wide 阅读量:372

参考代码:

<?php
 
    class Cm
    {
        public function cut()
        {
            $cut_m = 2;
            $i    = 0;                               
            $fp   = fopen("TC7.0.exe","rb");     	 
            $file = fopen("cut_msg.txt","a");     	
            while(!feof($fp)){  
                    $handle = fopen("temp.{$i}.temp","wb");  
                    fwrite($handle,fread($fp,$cut_m*1048576));
                    fwrite($file,"temp.{$i}.temp\r\n");  
                    fclose($handle);  
                    unset($handle);  
                    $i++;  
            }  
            fclose ($fp);  
            fclose ($file); 
        }
        
        public function merge()
        {
            $hash = file_get_contents("cut_msg.txt"); 
            $list = explode("\r\n",$hash);  
            $fp = fopen("TC7.0.new.exe","ab");      
            foreach($list as $value){  
                if(!empty($value)) {  
                    $handle = fopen($value,"rb");  
                    fwrite($fp,fread($handle,filesize($value)));  
                    fclose($handle);  
                    unset($handle);  
                }  
            }  
            fclose($fp);
        }
    }
    
    $cm = new Cm();
    $cm->cut();
效果:


--------------------- 
作者:橙虚缘 
来源:CSDN 
原文:https://blog.csdn.net/qq43599939/article/details/76221689?utm_source=copy 
版权声明:本文为博主原创文章,转载请附上博文链接!

上一篇:天气API接口

我要评论

Aoe WideAoe Wide   我要留言
Aoe Wide
Catfish(鲶鱼) Blog V 2.0.30