Mck - 2015-02-02 17:00:26 -
In reply to message 2 from Arash Hemmat
the merge method could be rewritten to
/*------------------------------------------------------------------
- MERGE -
- This function merges splited files that are splited with above -
- split_file function. -
--------------------------------------------------------------------*/
function merge_file($merged_file_name,$parts_num)
{
$content='';
//put splited files content into content
$mhandle=fopen($merged_file_name, 'wb') or die("error creating/opening merged file");
for($i=0;$i<$parts_num;$i++)
{
$file_size = filesize('splited_'.$i);
$handle = fopen('splited_'.$i, 'rb') or die("error opening file");
$content = fread($handle, $file_size) or die("error reading file");
fclose($handle);
//write content to merged file
fwrite($mhandle, $content) or die("error writing to merged file");
}
fclose($mhandle);
return 'OK';
}//end of function merge_file