1

We need to call a image file upload after paste a image. I need a solution for below issue. After pasted a image in particular div, how can we get pasted image as file object?.

i am using jquery.filedrop.js to done the "drag and drop" and browse button image file upload. but i can not able to do the ctrl v image file upload.

After drag and drop the image, we can get dropped image as file using the fllowing code "files = e.dataTransfer.files;".

But in paste (ctrl + v), we can not able to get in this way.

please suggest us how can we proceed for paste(ctrl + v) file uploader.

We use the jquery.filedrop.js from the following link:

http://www.github.com/weixiyen/jquery-filedrop

raj
  • 261
  • 3
  • 14
  • Because of security restriction I think you can't access the clipboard in Javascript. You have to use a flash plugin or similar to access the clipboard and retrieve your image. – ylerjen Jan 27 '14 at 07:48

1 Answers1

5

You could use hot keys plugin for jquery to catch ctrl+v event on keyup like this:

$(document).bind('keyup', 'Ctrl+v',function (evt){
    evt.preventDefault();
    call_uploader_here
});
Tom
  • 3,654
  • 2
  • 16
  • 23
  • thanks ji, one more question, how can i get pasted image as file format within this function? – raj Jan 27 '14 at 08:02
  • @raj Now I realized that my anwer is only some part of solution, I'm not sure how to handle files in that way. Try reading [this](http://stackoverflow.com/questions/10861618/copy-clipboard-image-into-webpage-using-jquery) or other linked there stack questions, hope it helps – Tom Jan 27 '14 at 08:31