PHP
·
发表于 5年以前
·
阅读量:8301
phpʵÏֶϵaÐø´«£¬¾ÍÐeÒª°Ñ´oÎļþ*Ö¸i³É¶a¸oСÎļþ£¬È»ºoµ¥¸oÉÏ´«¡£´«ÍeºoÔںϲ¢¡£
*(C)¦ merge.php ¨CºÏ²¢Îļþ½Å±¾
(C)¦ merge.zip ¨CºÏ²¢ºoÎļþ
(C)¦ socket.zip ¨CÐeÒªÖ¸iµÄÎļþ
(C)¦ split.php ¨CÖ¸iÎļþ½Å±¾
(C)¦
(C)¸(C)¤split ¨CÖ¸iºoСÎļþĿ¼**
ÏÂÃaeÊÇÔ´Âe
split.php
<?php
$fp = fopen("socket.zip", "rb");
$filesize = 10;
$i = 0;
$no = 1;
while(!feof($fp))
{
$file = fread($fp, $filesize);
$fp2 = fopen("./split/socket.port".sprintf("%04d",$no).".".$i."-".($i+$filesize).".tmp", "wb");
fwrite($fp2, $file, $filesize);
fclose($fp2);
$i+=$filesize+1;
$no++;
}
fclose($fp);
merge.php
<?php
$filelist = glob('./split/*socket*.tmp');
$filesize = 10;
//print_r($filelist);
$mergeFileName = 'merg.zip';
unlink($mergeFileName);
$fp2 = fopen($mergeFileName,"w+");
foreach($filelist as $k => $v)
{
$fp = fopen($v, "rb");
$content = fread($fp, $filesize);
fwrite($fp2, $content, $filesize);
unset($content);
fclose($fp);
echo $k,"\n";
}
fclose($fp2);
ÒÔÉϾÍÊDZ¾ÎĵÄÈ«²¿ÄÚÈÝ£¬Ï£Íu¶Ô´o¼ÒµÄѧϰÓÐËu°iÖu£¬Ò²Ï£Íu´o¼Ò¶a¶aÖ§³Ö½Å±¾Ö®¼Ò¡£