How can I let users upload files by copy/paste?

前端 未结 2 856
灰色年华
灰色年华 2021-01-04 21:06

I\'m trying to create a web app based on ExtJS, and I\'m working on the file-upload area of the app.

I want users to be able to upload files by copying and pasting

相关标签:
2条回答
  • 2021-01-04 21:26

    The thing is, that you're not able to access the clients filesystem with javascript. There is this new Filesystem API, but this just allows you to create a virtual sandboxed filesystem. I had the same problem, thought about it a while and came up with the following ideas.

    1. Flash

      Writing a Flash bridge which access the filesystem and let the javascript communicate with it via swliveconnect

      Problem: Flash doesn't have filesystem access either.

    2. Java applet

      Same thing as Flash and again with LiveConnect

      In my opinion this could work, but I didn't try it out, because my goal was to get filesystem access on a chromebook. And chromeOS doesn't support Java (at least without some hacking)

    3. ActiveX

      I also found some solutions with this. I gave up at the applet part so I didn't try this out either.

    As Jared Farrish said, when you copy a file the os just saves the path to the file in the clipboard. Then if you receive the paste event on your webapp just get the string out of the clipboard and forward it to your file bridge.

    0 讨论(0)
  • 2021-01-04 21:32

    I've seen that DropBox.com allows this to be done (in chrome- didn't seem to work in IE). I didn't do cut and paste specifically, but dragged files into a dropbox page from a local folder, and it uploaded the files. So, this doesnt directly answer your quesiton, but perhaps you can look at how this is done in their code.

    0 讨论(0)
提交回复
热议问题