4

In chrome, when I paste files into text areas, I end up with the path, e.g /home/antimatter15/sha1.js. The paste event includes a .clipboardData object, with stuff like the standard getData/setData methods. There's also a .files but it's length is always 0. Is there any way to get the file that's being pasted, possibly with FileReader like how files can be dragged.

antimatter15
  • 1,436
  • 1
  • 12
  • 18
  • probably it is not possible, I have checked this method to, but for security reason they do not allow this. – albanx Nov 30 '11 at 00:06
  • 1
    Definitely possible with Chrome. See http://stackoverflow.com/questions/6333814/how-does-the-paste-image-from-clipboard-functionality-work-in-gmail-and-google-c – a paid nerd Dec 01 '11 at 06:24

1 Answers1

1

I looked for something similar some time back, and to my knowledge this is not possible with JavaScript and html alone (at least not in any reliable way). Firefox and IE 9 appear to offer some support for local file reading, but for the vast majority of visitors to a public facing site you will need a Flash, Java, or ActiveX control in order to access the clipboard.

We were looking for this functionality for a helpdesk application and settled on an inexpensive ActiveX control called xStandard. As such, I never did any testing with Java to be able to comment on that part of your question. Hopefully someone else can elaborate on that approach.

Can you provide further information on your userbase and if the OS and browsers are controlled?

Nicholas
  • 1,974
  • 4
  • 20
  • 46