Upload Image From Clipboard

Hello. I want to add the functionality to upload an image from the clipboard. I have tried something like this:

Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
try {
   BufferedImage image = 
catch(UnsupportedFlavorException ufe) {
catch(IOException ioe) {

However, this code only works in the local machine. I want to click a button and then, the clipboard’s image will be uploaded to the server.

Thank you.