'error', 'message' => 'Не удалось открыть временный файл', 'size'=>0])); } // Если это последняя часть, переименовываем файл в итоговый if ($chunkIndex === $totalChunks - 1) { $finalFilePath = $uploadDir . $originalFilename; rename($tempFilePath, $finalFilePath); header('Content-Type: application/json; charset=utf-8'); echo json_encode(['status' => 'success', 'message' => 'Файл успешно собран', 'path' => $finalFilePath, 'size'=>filesize($finalFilePath)]); } else { header('Content-Type: application/json; charset=utf-8'); echo json_encode(['status' => 'uploading', 'chunk' => $chunkIndex, 'size' => filesize($tempFilePath)]); } } ?>