<?php

header('Content-type: text/json');

$post = $_POST;
$post['OK'] = 1;

if (!empty($_FILES)) {
	$file_field_name = key($_FILES);

	if (!$_FILES[$file_field_name]['error']) {
		$post[$file_field_name] = $_FILES[$file_field_name];
	}
}

echo json_encode($post);

<?php

$post = $_POST;
$post['OK'] = 1;

if (!empty($_FILES)) {
	$file_field_name = key($_FILES);

	if (!$_FILES[$file_field_name]['error']) {
		$post[$file_field_name] = $_FILES[$file_field_name];
	}
}

echo json_encode($post);

Remove header, it causes response to be downloaded as file.
Tests: Remove header, it causes response to be downloaded as file.
