如何让用户通过复制/粘贴上传文件? [英] How can I let users upload files by copy/paste?

查看:274
本文介绍了如何让用户通过复制/粘贴上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于ExtJS创建一个网络应用程序,并且正在处理该应用的文件上传区域。

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

我希望用户能够通过复制和粘贴上传文件 - 不仅仅是复制和粘贴文件的内容,而且是文件本身。例如,在Windows中,您可以在选择文件时从编辑菜单中选择复制或剪切,然后选择粘贴,然后复制或移动文件 - 我希望用户能够上传文件在粘贴步骤中的应用程序,只需在浏览器中选择粘贴即可。

I want users to be able to upload files by copying and pasting them - not just copying and pasting the contents of the file, but the file itself. For example, in Windows, you can choose "Copy" or "Cut" from the Edit menu while a file is selected, then choose "Paste" later and copy or move the file - I'd like users to be able to upload files to my app in the Paste step, by just choosing Paste in their browser.

我已经尝试过HTML5的拖放API,但我们不想使用 - 我们希望用户能够复制/剪切和粘贴文件上传他们的文件(只要它们小于20兆字节)。如果用户将路径复制到他们的文件和直接粘贴到页面的粘贴,告诉我们在哪里找到文件,这也可以正常工作。

I've already tried HTML5's drag-and-drop API, but we don't want to use that - we want users to be able to copy/cut and paste files to upload their files (as long as they're smaller than 20 megabytes). If the user copies the path to their file and pastes that directly to the page, telling us where to find the file, that could also work.

任何人都可以建议一种方式这样做?

Can anyone suggest a way to do this?

推荐答案

事情是,您无法使用javascript访问客户端文件系统。有新的 Filesystem API ,但这只允许您创建一个虚拟沙盒文件系统。我有同样的问题,想了一会儿,并提出了以下想法。

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

  1. Flash

编写一个访问文件系统的Flash Bridge,让javascript通过 swliveconnect

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

问题:Flash还没有文件系统访问。

Problem: Flash doesn't have filesystem access either.

Java小程序

与Flash相同,再次使用 LiveConnect

Same thing as Flash and again with LiveConnect

在我看来,这可以工作,但我没有尝试,因为我的目标是获取文件系统访问chromebook。而且chromeOS不支持Java(至少没有黑客)

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)

ActiveX

我也找到了一些解决方案。我放弃了小程序部分,所以我也没有尝试这个。

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

正如Jared Farrish所说,当你复制一个文件时,os只是把文件的路径保存在剪贴板中。然后,如果您在webapp上收到粘贴事件,只需将该字符串从剪贴板中取出,然后将其转发到文件桥。

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.

这篇关于如何让用户通过复制/粘贴上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆