Reading files from clipboard in Javascript
In chrome, when I paste files into text areas, I开发者_Python百科 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.
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?
精彩评论