require_once 'vendor/autoload.php';
$document = new \PhpOffice\PhpWord\TemplateProcessor('./Template.docx');
$uploadDir = __DIR__;
$outputFile = 'review_full.docx';
$uploadFile = $uploadDir . '\\' . basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile);
$birth = $_POST['birth'];
$name = $_POST['name'];
$tel = $_POST['tel'];
$city = $_POST['city'];
$full_program_name = $_POST['full_program_name'];
$program_level = $_POST['program_level'];
$program_direction = $_POST['program_direction'];
$document->setValue('name', $name);
$document->setValue('birth', $birth);
$document->setValue('tel', $tel);
$document->setValue('city', $city);
$document->setValue('full_program_name', $full_program_name);
$document->setValue('program_level', $program_level);
$document->setValue('program_direction', $program_direction);
$document->saveAs($outputFile);
$downloadFile = $outputFile;
header("Content-Type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Content-Length: ".filesize($downloadFile));
header("Content-Disposition: attachment; filename=".$downloadFile);
readfile($downloadFile);
unlink($uploadFile);
unlink($outputFile);