, 1 min read

Simple Web-Clipboard

Sometimes you want to store a simple text, like an URL, in a Citrix environment, which has copy-to clipboard functionality disabled. It would be handy if you could just copy the clipboard entry to another Citrix environment. I googled for "web clipboard". The listed solutions did not work. Below short PHP program solves this problem.

<html>
<title>Web clipboard</title>
<body>

<?php
    $fn = "/tmp/clb.txt";
    $maxlen = 4096;
    if ($_SERVER['REQUEST_METHOD'] === 'POST')
        file_put_contents($fn,substr($_POST['clb'],0,$maxlen));
?>

<form enctype="multipart/form-data" name=clb method=post action=clb.php>
    <textarea id=clb name=clb rows=12 cols=120 maxlength=<?=$maxlen?> autofocus placeholder="Enter text"><?= file_get_contents($fn) ?></textarea>
    <br><br>
    <input type=Submit value="Submit">
</form>

</body>
</html>

The "clipboard"-content is simply stored in a file on the web-server end. The size is arbitrarily limited to 4096 bytes. Initially the file is empty, and just keeps whatever is stored previously.

This solution is not well suited, when multiple people need this functionality simultaneously.