Clipboard

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Clipboard

Post 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 :(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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()">
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

I'll give it a try...
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Hmm, nothing.

Never mind, it was just a 'ooh, I wonder if this will work' sort of thing.

Thanks anyway.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it'd only print something if you paste into the html, it may require context... like a textarea or something..
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post 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)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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
Post Reply