Сделал вывод процесса загрузски
This commit is contained in:
13
upload.php
13
upload.php
@@ -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)]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user