Merge binaries: PHP Large file Storage example, various file segmentation and merging (binary segmentation and merging)

Source: Internet
Author: User
Tags fread split

Simple example:
split.php
<?php
$i = 0; Divided block number
$fp = fopen ("abc.wmv", "RB"); The file to split
$file = fopen ("Split_hash.txt", "a"); A text file that records the split information
while (!feof ($FP))
{
$handle = fopen ("abc.wmv.{ $i} "," WB ");
Fwrite ($handle, Fread ($fp, 5000000)); 5000000 can be customized. Is the size of each file split
Fwrite ($file, "qqdjz_002.wmv.{ $i}\r\n ");
Fclose ($handle);
Unset ($handle);
$i + +;
}
Fclose ($FP);
Fclose ($file);
echo "OK";
?>
join.php
<?php
$mov = file_get_contents ("Abc.txt"); Reading information for split files
$list = Explode ("\ r \ n", $mov);
$fp = fopen ("split.wmv", "AB"); Merged file name
foreach ($list as $value)
{
if (!empty ($value)) {
$handle = fopen ($value, "RB");
Fwrite ($fp, Fread ($handle, FileSize ($value));
Fclose ($handle);
Unset ($handle);
}
}
Fclose ($FP);
?>
This article links http://www.cxybl.com/html/wlbc/Php/20130326/37393.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.