How to copy string to system clipboard with php which runs as client side? -
i want copy string system clipboard php(which running client script) on mac osx.
why want function?
i'm writing php script runs client script on mac osx. it's used upload text website , download text local mac osx, , want copy these text mac's system clipboard.
so, there way copy string system clipboard php on mac osx?
php doesn't provide system clipboard api, can use php's proc_fopen call shell command pbcopy on mac os x retrieve function:
echo copy2clipboard('string'); function copy2clipboard($string){ $descriptorspec = array( 0 => array("pipe", "r"), // stdin pipe child read 1 => array("pipe", "w"), // stdout pipe child write 2 => array("file", "a.txt", "a") // stderr file write ); $process = proc_open('pbcopy', $descriptorspec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $string); fclose($pipes[0]); fclose($pipes[1]); $return_value = proc_close($process); return $return_value; } }
Comments
Post a Comment