When PHP implements breakpoint continuous transmission, it requires dividing large files into multiple small files and uploading them individually. Merge after the transmission.
│ – Merge file scripts
│ – Merged files
│ – Files that need to be split
│ – Segment file script
│
└─split – Small file directory after splitting
Below is the source code
<?php $fp = fopen("", "rb"); $filesize = 10; $i = 0; $no = 1; while(!feof($fp)) { $file = fread($fp, $filesize); $fp2 = fopen("./split/".sprintf("%04d",$no).".".$i."-".($i+$filesize).".tmp", "wb"); fwrite($fp2, $file, $filesize); fclose($fp2); $i+=$filesize+1; $no++; } fclose($fp);
<?php $filelist = glob('./split/*socket*.tmp'); $filesize = 10; //print_r($filelist); $mergeFileName = ''; 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);
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.