Page 1 of 1
Clipboard
Posted: Mon May 24, 2004 4:18 am
by Grim...
The answer to this may use javascript, but I'm not sure, so...
Say someone does a screen print, which puts the image into their clipboard.
Is it possible for PHP to upload the contents of the clipboard as part of a form?
This would be easy to do if the clipboard was a certain file in a certain place on the PC, but I can't find it

Posted: Mon May 24, 2004 8:21 am
by feyd
You're right, it is javascript. I don't quite remember if this event is stored in Mozilla and it's variants, but in IE there's window.onpaste() which defaults to null. I'm not entirely sure if you can force IE to paste or not, if possible, it would probably be window.paste()
The clipboard is only stored in active memory.
Posted: Mon May 24, 2004 8:57 am
by Grim...
Okay, well, I suck a JS
How would I get that into a hidden form field?
Code: Select all
<input type="hidden" name="clipboard" value="window.onpaste()">
Posted: Mon May 24, 2004 9:07 am
by feyd
that's a good question, and I have no idea what comes into the function, or whether it'd even work with binary data..
can always test it..
Code: Select all
<?php ?>
<script language="Javascript">
function handlePaste()
{
if(arguments.length == 0) document.write("no params to handlePaste()");
else
{
for(var x = 0; x < arguments.length; x++)
{
document.writeln(x+" = "+arguments[x]+"<br />");
}
}
}
window.onpaste = handlePaste;
</script>
NOT TESTED
Posted: Mon May 24, 2004 9:35 am
by Grim...
I'll give it a try...
Posted: Mon May 24, 2004 9:45 am
by Grim...
Hmm, nothing.
Never mind, it was just a 'ooh, I wonder if this will work' sort of thing.
Thanks anyway.
Posted: Mon May 24, 2004 9:49 am
by feyd
it'd only print something if you paste into the html, it may require context... like a textarea or something..
Posted: Mon May 24, 2004 10:19 am
by d3ad1ysp0rk
I'm sure a java applet would be able to handle pasting an image into an area, then converting it to binary before sending it to a php page to be saved to a database, or into an image.
Posted: Mon May 24, 2004 11:43 am
by vigge89
if you would just use text, you could possible echo the clipboard-content into an hidden-field with JS, and then submit it (either with user clicking or JS)
Posted: Mon May 24, 2004 11:48 am
by d3ad1ysp0rk
vigge89 wrote:if you would just use text, you could possible echo the clipboard-content into an hidden-field with JS, and then submit it (either with user clicking or JS)
He was talking about images, not text