<?php

$chunk = $_FILES['chunk']['tmp_name'];
$index = $_POST['index'];
$name = $_POST['name'];

$dir = __DIR__ . '/../uploads/chunks/';
if(!is_dir($dir)) mkdir($dir, 0777, true);

move_uploaded_file($chunk, $dir . $name . "_" . $index);

echo "chunk saved";