first commit

This commit is contained in:
2025-05-02 01:32:22 +03:00
commit 0311b21d23
5 changed files with 195 additions and 0 deletions

21
merge_chunks.php Normal file
View 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);