65536) { http_response_code(413); echo "Upload too large"; exit; } $mime = (new finfo(FILEINFO_MIME_TYPE))->file($temp); $content = file_get_contents($temp); if ($mime !== "text/plain" || $content === false || !mb_check_encoding($content,"UTF-8") || str_contains($content,"\0")) { http_response_code(415); echo "Use plain UTF-8 text"; exit; } $target = sys_get_temp_dir() . "/bhylu-upload-" . bin2hex(random_bytes(16)) . ".txt"; if (!move_uploaded_file($temp,$target)) { http_response_code(500); echo "Storage failed"; exit; } try { echo "Stored ", filesize($target), " bytes privately"; } finally { unlink($target); }