合并二进制文件:PHP大文件存储示例,各种文件分割和合并(二进制分割与合并)
程序员文章站
2022-05-15 16:03:09
...
简单示例:
本文链接http://www.cxybl.com/html/wlbc/Php/20130326/37393.html
split.php $i = 0; //分割的块编号 $fp = fopen("abc.wmv","rb"); //要分割的文件 $file = fopen("split_hash.txt","a"); //记录分割的信息的文本文件 while(!feof($fp)) { $handle = fopen("abc.wmv.{$i}","wb"); fwrite($handle,fread($fp,5000000)); //5000000 可以自定义.就是每个所分割的文件大小 fwrite($file,"qqdjz_002.wmv.{$i}\r\n"); fclose($handle); unset($handle); $i++; } fclose ($fp); fclose ($file); echo "ok"; ?> join.php $mov = file_get_contents("abc.txt"); //读取分割文件的信息 $list = explode("\r\n",$mov); $fp = fopen("split.wmv","ab"); //合并后的文件名 foreach($list as $value) { if(!empty($value)) { $handle = fopen($value,"rb"); fwrite($fp,fread($handle,filesize($value))); fclose($handle); unset($handle); } } fclose($fp); ?> |