Сделал вывод процесса загрузски

This commit is contained in:
2026-05-21 22:30:56 +03:00
parent b903cca6e2
commit 8d5ab828c1
3 changed files with 72 additions and 12 deletions

View File

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