22 lines
548 B
PHP
22 lines
548 B
PHP
<?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);
|