$fileName = isset($_POST['name']) ? $_POST['name'] : "";
$fileSize = isset($_POST['size']) ? $_POST['size'] : "";
if (null === $id || !$fileName || !$fileSize) {
    Json::error("you have to send 'id','name' and 'size' to start processing");
    exit;
}
// the next lines terminates the output buffer and let believe the requester that the program had finished
ob_start();
Json::ok();
header("Content-Length: " . ob_get_length());
header('Connection: close');
ob_end_flush();
flush();
session_write_close();
$status = new Status($_POST["_task"]);
$status->touchStatusFile();
// wait a little before the huge work
sleep(1);
$status->updateStatus($id, Status::PROCESSING);
process($status, $id, $fileName, $fileSize);
$status->updateStatus($id, Status::DONE);
sleep(2);
// give time to frontend to recover updated status
$status->freeStatusFile();
/**
 * @param Status $status
 * @param int $id
 * @param String $name
 * @param int $size
 */
function process(Status $status, $id, $name, $size)