first commit
This commit is contained in:
21
merge_chunks.php
Normal file
21
merge_chunks.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$filename = basename($data['filename']);
|
||||
$total = intval($data['total']);
|
||||
$tmpDir = __DIR__ . '/upload_chunks/' . $filename;
|
||||
$finalPath = __DIR__ . '/upload/' . $filename;
|
||||
|
||||
$out = fopen($finalPath, 'w');
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
$partPath = "$tmpDir/$i.part";
|
||||
$in = fopen($partPath, 'r');
|
||||
stream_copy_to_stream($in, $out);
|
||||
fclose($in);
|
||||
unlink($partPath);
|
||||
}
|
||||
fclose($out);
|
||||
rmdir($tmpDir);
|
||||
http_response_code(200);
|
||||
Reference in New Issue
Block a user