Copy CodeThe code is as follows:
Ini_set ("Memory_limit", "50M");//must, according to the actual situation of your environment as large as possible to prevent errors
Ini_set ("Max_execution_time", "100");
The file_exists () function checks whether a file or directory exists, returns True if it exists, or false otherwise.
The Fread () function reads the file (which can be used safely in binary files). Fread () reads up to length bytes from file pointer files.
The FileSize () function returns the size (in bytes) of the specified file. The result of this function is cached. Please use Clearstatcache () to clear the cache.
$orgFile = ' fireworks8-chs.exe ';//source file
$cacheFileName = ' vbcache ';//split into a temporary file block
function Cutfile ($fileName, $block) {//Split
Global $cacheFileName;
if (!file_exists ($fileName)) return false;
$num = 1;
$file = fopen ($fileName, ' RB ');
while ($content = Fread ($file, $block)) {
$cacheFile = $cacheFileName. $num + +. '. Dat ';
$cfile = fopen ($cacheFile, ' WB ');
Fwrite ($cfile, $content);
Fclose ($cfile);
}
Fclose ($file);
}
function Mergefile ($targetFile) {//merge
Global $cacheFileName;
$num = 1;
$file = fopen ($targetFile, ' WB ');
while ($num > 0) {
$cacheFile = $cacheFileName. $num + +. '. Dat ';
if (file_exists ($cacheFile)) {
$cfile = fopen ($cacheFile, ' RB ');
$content = Fread ($cfile, FileSize ($cacheFile));
Fclose ($cfile);
Fwrite ($file, $content);
}
else {
$num =-1;
}
}
Fclose ($file);
}
Call
Cutfile ($orgFile, ten * POW (2,20)); Ten * POW (2,20) equals the 10M Pow () function returns the Y-order of X
Mergefile (' Ok.exe ');
?>
http://www.bkjia.com/PHPjc/744708.html www.bkjia.com true http://www.bkjia.com/PHPjc/744708.html techarticle Copy the code as follows: Php ini_set ("Memory_limit", "50M"),//must, according to the actual situation of your environment as large as possible to prevent error Ini_set ("Max_execution_time", "100"); File_exi ...