This article is mainly for you to introduce the PHP breakpoint continuation of the file segmentation and merging, with a certain reference value, interested in small partners can refer to
PHP implementation of the breakpoint continuation, you need to split the large file into a number of small files, and then single upload. After the transfer is completed in the merge.
│merge.php– Merging file scripts
│merge.zip– after merging files
│socket.zip– files that need to be split
│split.php– Split File Script
│
└─split– small file directory after splitting
Here is the source code
split.php
<?PHP$FP = fopen ("Socket.zip", "RB"), $filesize = ten; $i = 0; $no = 1;while (!feof ($fp)) { $file = fread ($fp, $filesize) ; $FP 2 = fopen ("./split/socket.port". sprintf ("%04d", $no). ".". $i. " -". ($i + $filesize). ". TMP "," WB "); Fwrite ($fp 2, $file, $filesize); Fclose ($fp 2); $i + = $filesize +1; $no + +;} Fclose ($FP);
merge.php
<?php$filelist = Glob ('./split/*socket*.tmp '); $filesize = 10;//print_r ($ filelist); $mergeFileName = ' merg.zip '; unlink ($mergeFileName); $FP 2 = fopen ($mergeFileName, "w+"), foreach ($filelist as $k = = $v) {$fp = fopen ($v, "RB"); $content = Fread ($fp, $filesize); Fwrite ($fp 2, $content, $filesize); Unset ($content); Fclose ($FP); echo $k, "\ n";} Fclose ($fp 2);